-- | Provides the 'MSpace' typeclass.
--
-- @since 0.1
module Numeric.Algebra.Space.MSpace
  ( MSpace (..),
    (%.),
  )
where

import Data.Kind (Constraint, Type)
import Numeric.Algebra.Multiplicative.MGroup (MGroup ((.%.)))
import Numeric.Algebra.Space.MSemiSpace (MSemiSpace)

-- | Defines a "multiplicative space" over an 'MGroup'. This generalizes
-- the notion of a 'Numeric.Algebra.Space.SemivectorSpace.Semivectorspace'
-- \(V\) over a 'Numeric.Algebra.Semifield.Semifield' \(K\) in that we
-- assume no additive structure on the space itself.
--
-- @since 0.1
type MSpace :: Type -> Type -> Constraint
class (MGroup k, MSemiSpace v k) => MSpace v k | v -> k where
  -- | @since 0.1
  (.%) :: v -> k -> v

infixl 7 .%

-- | @since 0.1
(%.) :: (MSpace v k) => k -> v -> v
%. :: forall v k. MSpace v k => k -> v -> v
(%.) = (v -> k -> v) -> k -> v -> v
forall a b c. (a -> b -> c) -> b -> a -> c
flip v -> k -> v
forall v k. MSpace v k => v -> k -> v
(.%)
{-# INLINE (%.) #-}

infixl 7 %.

-- | @since 0.1
instance (MGroup k) => MSpace (k, k) k where
  (k
x1, k
x2) .% :: (k, k) -> k -> (k, k)
.% k
k = (k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k)
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k) k where
  (k
x1, k
x2, k
x3) .% :: (k, k, k) -> k -> (k, k, k)
.% k
k = (k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k)
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4) .% :: (k, k, k, k) -> k -> (k, k, k, k)
.% k
k = (k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k, k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k)
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4, k
x5) .% :: (k, k, k, k, k) -> k -> (k, k, k, k, k)
.% k
k =
    ( k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x5 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k
    )
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4, k
x5, k
x6) .% :: (k, k, k, k, k, k) -> k -> (k, k, k, k, k, k)
.% k
k =
    ( k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x5 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x6 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k
    )
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4, k
x5, k
x6, k
x7) .% :: (k, k, k, k, k, k, k) -> k -> (k, k, k, k, k, k, k)
.% k
k =
    ( k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x5 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x6 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x7 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k
    )
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k, k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4, k
x5, k
x6, k
x7, k
x8) .% :: (k, k, k, k, k, k, k, k) -> k -> (k, k, k, k, k, k, k, k)
.% k
k =
    ( k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x5 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x6 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x7 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x8 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k
    )
  {-# INLINE (.%) #-}

-- | @since 0.1
instance (MGroup k) => MSpace (k, k, k, k, k, k, k, k, k) k where
  (k
x1, k
x2, k
x3, k
x4, k
x5, k
x6, k
x7, k
x8, k
x9) .% :: (k, k, k, k, k, k, k, k, k) -> k -> (k, k, k, k, k, k, k, k, k)
.% k
k =
    ( k
x1 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x2 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x3 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x4 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x5 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x6 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x7 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x8 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k,
      k
x9 k -> k -> k
forall g. MGroup g => g -> g -> g
.%. k
k
    )
  {-# INLINE (.%) #-}