plankton-0.0.0.1: The core of a numeric prelude, taken from numhask

Safe HaskellSafe
LanguageHaskell2010

Plankton.Magma

Description

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.

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 (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