Portability | portable |
---|---|

Stability | provisional |

Maintainer | ross@soi.city.ac.uk |

Classes corresponding to common structures from abstract algebra.

- class AbelianGroup a where
- class AbelianGroup a => Ring a where
- (*) :: a -> a -> a
- fromInteger :: Integer -> a

- class (Eq a, Ring a) => EuclideanDomain a where
- class Ring a => Field a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a

- subtract :: AbelianGroup a => a -> a -> a
- gcd :: EuclideanDomain a => a -> a -> a
- lcm :: EuclideanDomain a => a -> a -> a
- realToField :: (Real a, Field b) => a -> b

# Classes

class AbelianGroup a whereSource

An Abelian group has an commutative associative binary operation with an identity and inverses.

The identity of `(`

.
`+`

)

A commutative associative operation with identity `zero`

.

Inverse for `(`

(unary negation).
`+`

)

AbelianGroup Double | |

AbelianGroup Float | |

AbelianGroup Int | |

AbelianGroup Integer | |

EuclideanDomain a => AbelianGroup (Ratio a) | |

AbelianGroup a => AbelianGroup (Complex a) | |

AbelianGroup a => AbelianGroup (Vector a) | |

AbelianGroup a => AbelianGroup (Matrix a) | |

AbelianGroup a => AbelianGroup (Polynomial a) | |

(AbelianGroup a, AbelianGroup b) => AbelianGroup (a, b) | Direct product |

AbelianGroup a => AbelianGroup (Quantity u a) |

class AbelianGroup a => Ring a whereSource

A ring: addition forms an Abelian group, and multiplication defines a monoid and distributes over addition. Multiplication is not guaranteed to be commutative.

Minimal complete definition: `(`

and `*`

)`fromInteger`

.

An associative operation with identity

,
distributing over `fromInteger`

1`(`

and `+`

)`zero`

.

fromInteger :: Integer -> aSource

Conversion from `Integer`

, the initial ring:
`fromInteger`

is the unique function preserving `zero`

, `(`

,
`+`

)`(`

and `-`

)`(`

, and for which `*`

)

is the
identity of `fromInteger`

1`(`

.
`*`

)

An integer literal represents the application of the function
`fromInteger`

to the appropriate value of type `Integer`

,
so such literals have type `(`

.
`Ring`

a) => a

class (Eq a, Ring a) => EuclideanDomain a whereSource

A integral domain (a non-trivial commutative `Ring`

with no zero
divisors) on which the Euclid's algorithm for `gcd`

works.

Minimal complete definition:
(`divMod`

or (`div`

and `mod`

)) and `unit`

.

Division with remainder: for any `d /= 0`

,

n ==

`div`

n d * d +`mod`

n d`mod`

(n + a*d) d ==`mod`

n d-

is smaller than`mod`

n d`d`

in some well-founded order.

For integral types,

is a non-negative integer smaller
than the absolute value of `mod`

n d`d`

.

EuclideanDomain Int | |

EuclideanDomain Integer | |

Integral a => EuclideanDomain (Complex a) | Gaussian integers:
if |

(Eq a, Field a) => EuclideanDomain (Polynomial a) | If |

class Ring a => Field a whereSource

A commutative `Ring`

in which all non-zero elements have multiplicative
inverses.

Multiplicative inverse.

fromRational :: Rational -> aSource

Convert from `Rational`

A floating point numeric literal represents the application of
the function `fromRational`

to the appropriate value of type
`Rational`

, so such literals have type `(`

.
`Field`

a) => a

# Utility functions

subtract :: AbelianGroup a => a -> a -> aSource

gcd :: EuclideanDomain a => a -> a -> aSource

lcm :: EuclideanDomain a => a -> a -> aSource

realToField :: (Real a, Field b) => a -> bSource

General conversion to fields, via the `Rational`

type.