{-# LANGUAGE TypeFamilies #-}
module NumHask.Algebra.Action
( AdditiveAction (..),
(+|),
SubtractiveAction (..),
(-|),
MultiplicativeAction (..),
(*|),
DivisiveAction (..),
(/|),
Module,
)
where
import Data.Kind (Type)
import NumHask.Algebra.Additive (Additive, Subtractive, negate)
import NumHask.Algebra.Multiplicative (Divisive, Multiplicative, recip)
import NumHask.Algebra.Ring (Distributive)
import Prelude (flip)
class
(Additive (AdditiveScalar m)) =>
AdditiveAction m
where
type AdditiveScalar m :: Type
infixl 6 |+
(|+) :: m -> AdditiveScalar m -> m
infixl 6 +|
(+|) :: (AdditiveAction m) => AdditiveScalar m -> m -> m
+| :: forall m. AdditiveAction m => AdditiveScalar m -> m -> m
(+|) = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall m. AdditiveAction m => m -> AdditiveScalar m -> m
(|+)
class
(AdditiveAction m, Subtractive (AdditiveScalar m)) =>
SubtractiveAction m
where
infixl 6 |-
(|-) :: m -> AdditiveScalar m -> m
infixl 6 -|
(-|) :: (AdditiveAction m, Subtractive m) => AdditiveScalar m -> m -> m
AdditiveScalar m
a -| :: forall m.
(AdditiveAction m, Subtractive m) =>
AdditiveScalar m -> m -> m
-| m
b = AdditiveScalar m
a forall m. AdditiveAction m => AdditiveScalar m -> m -> m
+| forall a. Subtractive a => a -> a
negate m
b
class
(Multiplicative (Scalar m)) =>
MultiplicativeAction m
where
type Scalar m :: Type
infixl 7 |*
(|*) :: m -> Scalar m -> m
infixl 7 *|
(*|) :: (MultiplicativeAction m) => Scalar m -> m -> m
*| :: forall m. MultiplicativeAction m => Scalar m -> m -> m
(*|) = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall m. MultiplicativeAction m => m -> Scalar m -> m
(|*)
class
(Divisive (Scalar m), MultiplicativeAction m) =>
DivisiveAction m
where
infixl 7 |/
(|/) :: m -> Scalar m -> m
(/|) :: (MultiplicativeAction m, Divisive m) => Scalar m -> m -> m
Scalar m
a /| :: forall m.
(MultiplicativeAction m, Divisive m) =>
Scalar m -> m -> m
/| m
b = Scalar m
a forall m. MultiplicativeAction m => Scalar m -> m -> m
*| forall a. Divisive a => a -> a
recip m
b
type Module m = (Distributive (Scalar m), MultiplicativeAction m)