Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Bootstrapping the number system.
This heirarchy is repeated for the Additive and Multiplicative structures, in order to achieve class separation, so these classes are not used in the main numerical classes.
- class Magma a where
- class Magma a => Unital a where
- class Magma a => Associative a
- class Magma a => Commutative a
- class Magma a => Invertible a where
- class Magma a => Idempotent a
- class (Associative a, Unital a) => Monoidal a
- class (Commutative a, Associative a, Unital a) => CMonoidal a
- class (Unital a, Invertible a) => Loop a
- class (Associative a, Unital a, Invertible a) => Group a
- groupSwap :: Group a => (a, a) -> (a, a)
- class (Associative a, Unital a, Invertible a, Commutative a) => Abelian a
Documentation
A Magma is a tuple (T,⊕) consisting of
- a type a, and
- a function (⊕) :: T -> T -> T
The mathematical laws for a magma are:
- ⊕ is defined for all possible pairs of type T, and
- ⊕ is closed in the set of all possible values of type T
or, more tersly,
∀ a, b ∈ T: a ⊕ b ∈ T
These laws are true by construction in haskell: the type signature of magma
and the above mathematical laws are synonyms.
class Magma a => Associative a Source #
An Associative Magma
(a ⊕ b) ⊕ c = a ⊕ (b ⊕ c)
class Magma a => Commutative a Source #
A Commutative Magma
a ⊕ b = b ⊕ a
class Magma a => Invertible a where Source #
An Invertible Magma
∀ a ∈ T: inv a ∈ T
law is true by construction in Haskell
class Magma a => Idempotent a Source #
An Idempotent Magma
a ⊕ a = a
class (Associative a, Unital a) => Monoidal a Source #
A Monoidal Magma is associative and unital.
class (Commutative a, Associative a, Unital a) => CMonoidal a Source #
A CMonoidal Magma is commutative, associative and unital.
class (Unital a, Invertible a) => Loop a Source #
A Loop is unital and invertible
class (Associative a, Unital a, Invertible a) => Group a Source #
A Group is associative, unital and invertible
class (Associative a, Unital a, Invertible a, Commutative a) => Abelian a Source #
An Abelian Group is associative, unital, invertible and commutative