numhask-0.0.3: A numeric prelude

Safe HaskellSafe
LanguageHaskell2010

NumHask.Algebra.Magma

Description

Magma

Synopsis

Documentation

class Magma a where Source #

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.

Minimal complete definition

(⊕)

Methods

(⊕) :: a -> a -> a Source #

class Magma a => Unital a where Source #

A Unital Magma

unit ⊕ a = a
a ⊕ unit = a

Minimal complete definition

unit

Methods

unit :: a Source #

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

Minimal complete definition

inv

Methods

inv :: a -> a Source #

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

Minimal complete definition

hom

Methods

hom :: a -> b Source #

Instances

Magma a => Homomorphic a a Source # 

Methods

hom :: a -> a Source #

class (Magma a, Magma b) => Isomorphic a b where Source #

major conceptual clashidge with many other libraries

Minimal complete definition

isomorph

Methods

isomorph :: (a -> b, b -> a) Source #

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