| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
NumHask.Algebra.Additive
Description
A magma heirarchy for addition. The basic magma structure is repeated and prefixed with 'Additive-'.
Synopsis
- class AdditiveMagma a where
- class AdditiveMagma a => AdditiveUnital a where
- class AdditiveMagma a => AdditiveAssociative a
- class AdditiveMagma a => AdditiveCommutative a
- class AdditiveMagma a => AdditiveInvertible a where
- class AdditiveMagma a => AdditiveIdempotent a
- sum :: (Additive a, Foldable f) => f a -> a
- class (AdditiveCommutative a, AdditiveUnital a, AdditiveAssociative a) => Additive a where
- class (AdditiveUnital a, AdditiveAssociative a, AdditiveInvertible a) => AdditiveRightCancellative a where
- class (AdditiveUnital a, AdditiveAssociative a, AdditiveInvertible a) => AdditiveLeftCancellative a where
- class (Additive a, AdditiveInvertible a) => AdditiveGroup a where
- subtract :: AdditiveGroup a => a -> a -> a
Documentation
class AdditiveMagma a where #
plus is used as the operator for the additive magma to distinguish from + which, by convention, implies commutativity
∀ a,b ∈ A: a `plus` b ∈ A
law is true by construction in Haskell
Minimal complete definition
Instances
| AdditiveMagma Bool # | |
| AdditiveMagma Double # | |
| AdditiveMagma Float # | |
| AdditiveMagma Int # | |
| AdditiveMagma Int8 # | |
| AdditiveMagma Int16 # | |
| AdditiveMagma Int32 # | |
| AdditiveMagma Int64 # | |
| AdditiveMagma Integer # | |
| AdditiveMagma Natural # | |
| AdditiveMagma Word # | |
| AdditiveMagma Word8 # | |
| AdditiveMagma Word16 # | |
| AdditiveMagma Word32 # | |
| AdditiveMagma Word64 # | |
| AdditiveMagma a => AdditiveMagma (Complex a) # | |
| (Ord a, Integral a, Signed a, AdditiveInvertible a) => AdditiveMagma (Ratio a) # | |
| AdditiveMagma a => AdditiveMagma (Complex a) # | |
| AdditiveMagma a => AdditiveMagma (Sum a) # | |
| (ExpField a, LowerBoundedField a, Ord a) => AdditiveMagma (LogField a) # | |
class AdditiveMagma a => AdditiveUnital a where #
Unital magma for addition.
zero `plus` a == a a `plus` zero == a
Minimal complete definition
Instances
class AdditiveMagma a => AdditiveAssociative a #
Associative magma for addition.
(a `plus` b) `plus` c == a `plus` (b `plus` c)
Instances
class AdditiveMagma a => AdditiveCommutative a #
Commutative magma for addition.
a `plus` b == b `plus` a
Instances
class AdditiveMagma a => AdditiveInvertible a where #
Invertible magma for addition.
∀ a ∈ A: negate a ∈ A
law is true by construction in Haskell
Minimal complete definition
Instances
class AdditiveMagma a => AdditiveIdempotent a #
Idempotent magma for addition.
a `plus` a == a
Instances
| AdditiveIdempotent Bool # | |
Defined in NumHask.Algebra.Additive | |
sum :: (Additive a, Foldable f) => f a -> a #
sum definition avoiding a clash with the Sum monoid in base fixme: fit in with the Sum monoid
class (AdditiveCommutative a, AdditiveUnital a, AdditiveAssociative a) => Additive a where #
Additive is commutative, unital and associative under addition
zero + a == a a + zero == a (a + b) + c == a + (b + c) a + b == b + a
Instances
| Additive Bool # | |
| Additive Double # | |
| Additive Float # | |
| Additive Int # | |
| Additive Int8 # | |
| Additive Int16 # | |
| Additive Int32 # | |
| Additive Int64 # | |
| Additive Integer # | |
| Additive Natural # | |
| Additive Word # | |
| Additive Word8 # | |
| Additive Word16 # | |
| Additive Word32 # | |
| Additive Word64 # | |
| Additive a => Additive (Complex a) # | |
| (Ord a, Signed a, Integral a, AdditiveInvertible a) => Additive (Ratio a) # | |
| Additive a => Additive (Complex a) # | |
| (AdditiveUnital a, AdditiveMagma a) => Additive (Sum a) # | |
| (LowerBoundedField a, ExpField a, Ord a) => Additive (LogField a) # | |
class (AdditiveUnital a, AdditiveAssociative a, AdditiveInvertible a) => AdditiveRightCancellative a where #
Non-commutative right minus
a `plus` negate a = zero
class (AdditiveUnital a, AdditiveAssociative a, AdditiveInvertible a) => AdditiveLeftCancellative a where #
Non-commutative left minus
negate a `plus` a = zero
class (Additive a, AdditiveInvertible a) => AdditiveGroup a where #
Minus (-) is reserved for where both the left and right cancellative laws hold. This then implies that the AdditiveGroup is also Abelian.
Syntactic unary negation - substituting "negate a" for "-a" in code - is hard-coded in the language to assume a Num instance. So, for example, using ''-a = zero - a' for the second rule below doesn't work.
a - a = zero negate a = zero - a negate a + a = zero a + negate a = zero
Instances
| AdditiveGroup Double # | |
| AdditiveGroup Float # | |
| AdditiveGroup Int # | |
| AdditiveGroup Int8 # | |
| AdditiveGroup Int16 # | |
| AdditiveGroup Int32 # | |
| AdditiveGroup Int64 # | |
| AdditiveGroup Integer # | |
| AdditiveGroup Word # | |
| AdditiveGroup Word8 # | |
| AdditiveGroup Word16 # | |
| AdditiveGroup Word32 # | |
| AdditiveGroup Word64 # | |
| AdditiveGroup a => AdditiveGroup (Complex a) # | |
| (Ord a, Signed a, Integral a, AdditiveGroup a) => AdditiveGroup (Ratio a) # | |
| AdditiveGroup a => AdditiveGroup (Complex a) # | |
| (AdditiveInvertible a, AdditiveUnital a) => AdditiveGroup (Sum a) # | |
subtract :: AdditiveGroup a => a -> a -> a #