Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Magma
- 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 (Magma a, Magma b) => Homomorphic a b where
- class (Magma a, Magma b) => Isomorphic a b where
- 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 (Magma a, Magma b) => Homomorphic a b where Source #
A Homomorph between two Magmas
∀ a ∈ A: hom a ∈ B
law is true by construction in Haskell
Magma a => Homomorphic a a Source # | |
class (Magma a, Magma b) => Isomorphic a b where Source #
major conceptual clashidge with many other libraries
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