semirings-0.7: two monoids as one, in holy haskimony

Safe Haskell | None
Language | Haskell98

Data.Field

Contents

- Field typeclass

Description

A `Field` is a `Ring` in which all nonzero elements have a multiplicative inverse.

Synopsis

- class (Euclidean a, Ring a) => Field a
- divide :: Field a => a -> a -> a
- fromRational :: Field a => Rational -> a
- recip :: Field a => a -> a
- (/) :: Field a => a -> a -> a

# Field typeclass

class (Euclidean a, Ring a) => Field a #

`Field` represents a field, a ring with a multiplicative inverse for any non-zero element.

#### Instances

Instances details

Field CDouble # |
Instance details Defined in Data.Euclidean
Field CFloat # |
Instance details Defined in Data.Euclidean
Field Mod2 # |
Instance details Defined in Data.Euclidean
Field () # |
Instance details Defined in Data.Euclidean
Field Double # |
Instance details Defined in Data.Euclidean
Field Float # |
Instance details Defined in Data.Euclidean
Field a => Field (Complex a) # |
Instance details Defined in Data.Euclidean
Integral a => Field (Ratio a) # |
Instance details Defined in Data.Euclidean
Fractional a => Field (WrappedFractional a) # |
Instance details Defined in Data.Euclidean

divide :: Field a => a -> a -> a infixl 7 #

Divide two elements of a `Field`. For any `Fractional` type, this is the same as `(/)`.

    x divide y = x times recip y

fromRational :: Field a => Rational -> a #

Convert from rational to field.

When `{-#` `LANGUAGE RebindableSyntax #-}` is enabled, this function is used for desugaring rational literals (like, `2.37`). This may be used to facilitate transition from `Fractional` to `Field`, because less casts are now required.

recip :: Field a => a -> a #

Invert an element of a `Field`. For any `Fractional` type, this is the same as `recip`.

    recip x times x = one

(/) :: Field a => a -> a -> a infixl 7 #

Infix shorthand for `divide`.