numeric-prelude-0.4.3.2: An experimental alternative hierarchy of numeric type classes

Safe HaskellNone
LanguageHaskell98

Algebra.Field

Contents

Synopsis

Class

class C a => C a Source #

Field again corresponds to a commutative ring. Division is partially defined and satisfies

   not (isZero b)  ==>  (a * b) / b === a
   not (isZero a)  ==>  a * recip a === one

when it is defined. To safely call division, the program must take type-specific action; e.g., the following is appropriate in many cases:

safeRecip :: (Integral a, Eq a, Field.C a) => a -> Maybe a
safeRecip x =
    let (q,r) = one `divMod` x
    in  toMaybe (isZero r) q

Typical examples include rationals, the real numbers, and rational functions (ratios of polynomial functions). An instance should be typically declared only if most elements are invertible.

Actually, we have also used this type class for non-fields containing lots of units, e.g. residue classes with respect to non-primes and power series. So the restriction not (isZero a) must be better isUnit a.

Minimal definition: recip or (/)

Minimal complete definition

recip | (/)

Instances
C Double Source # 
Instance details

Defined in Algebra.Field

C Float Source # 
Instance details

Defined in Algebra.Field

C T Source # 
Instance details

Defined in Number.GaloisField2p32m5

Methods

(/) :: T -> T -> T Source #

recip :: T -> T Source #

fromRational' :: Rational -> T Source #

(^-) :: T -> Integer -> T Source #

C T Source # 
Instance details

Defined in Number.FixedPoint.Check

Methods

(/) :: T -> T -> T Source #

recip :: T -> T Source #

fromRational' :: Rational -> T Source #

(^-) :: T -> Integer -> T Source #

C T Source # 
Instance details

Defined in Number.Positional.Check

Methods

(/) :: T -> T -> T Source #

recip :: T -> T Source #

fromRational' :: Rational -> T Source #

(^-) :: T -> Integer -> T Source #

Integral a => C (Ratio a) Source # 
Instance details

Defined in Algebra.Field

RealFloat a => C (Complex a) Source # 
Instance details

Defined in Algebra.Field

(Ord a, C a) => C (T a) Source # 
Instance details

Defined in Number.NonNegative

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Algebra.Field

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

Fractional a => C (T a) Source # 
Instance details

Defined in MathObj.Wrapper.Haskell98

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.ResidueClass.Func

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

(Eq a, C a) => C (T a) Source # 
Instance details

Defined in Number.ResidueClass.Check

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.PartiallyTranscendental

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in MathObj.PowerSeries

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in MathObj.PowerSeries2

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.PowerSum

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.RootSet

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.Complex

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.LaurentPolynomial

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in MathObj.Wrapper.NumericPrelude

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

C v => C (T a v) Source # 
Instance details

Defined in Number.OccasionallyScalarExpression

Methods

(/) :: T a v -> T a v -> T a v Source #

recip :: T a v -> T a v Source #

fromRational' :: Rational -> T a v Source #

(^-) :: T a v -> Integer -> T a v Source #

(IsScalar u, C a) => C (T u a) Source # 
Instance details

Defined in Number.DimensionTerm

Methods

(/) :: T u a -> T u a -> T u a Source #

recip :: T u a -> T u a Source #

fromRational' :: Rational -> T u a Source #

(^-) :: T u a -> Integer -> T u a Source #

(Ord i, C a) => C (T i a) Source # 
Instance details

Defined in Number.Physical

Methods

(/) :: T i a -> T i a -> T i a Source #

recip :: T i a -> T i a Source #

fromRational' :: Rational -> T i a Source #

(^-) :: T i a -> Integer -> T i a Source #

C v => C (T a v) Source # 
Instance details

Defined in Number.SI

Methods

(/) :: T a v -> T a v -> T a v Source #

recip :: T a v -> T a v Source #

fromRational' :: Rational -> T a v Source #

(^-) :: T a v -> Integer -> T a v Source #

(/) :: C a => a -> a -> a infixl 7 Source #

recip :: C a => a -> a Source #

fromRational :: C a => Rational -> a Source #

Needed to work around shortcomings in GHC.

(^-) :: C a => a -> Integer -> a infixr 8 Source #

Properties

propDivision :: (Eq a, C a, C a) => a -> a -> Property Source #

the restriction on the divisor should be isUnit a instead of not (isZero a)

propReciprocal :: (Eq a, C a, C a) => a -> Property Source #