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

Safe HaskellSafe-Infered




class (C a, C a) => C a whereSource

The two classes C and C exist to allow convenient conversions, primarily between the built-in types. They should satisfy

   fromInteger .  toInteger === id
    toRational .  toInteger === toRational

Conversions must be lossless, that is, they do not round in any way. For rounding see Algebra.RealRing.

I think that the RealIntegral superclass is too restrictive. Non-negative numbers are not a ring, but can be easily converted to Integers.


toInteger :: a -> IntegerSource


C Int 
C Int8 
C Int16 
C Int32 
C Int64 
C Integer 
C Word 
C Word8 
C Word16 
C Word32 
C Word64 
C T 
C a => C (T a) 
Integral a => C (T a) 
C a => C (T a) 
(C a, C a) => C (T a) 

fromIntegral :: (C a, C b) => a -> bSource

ringPower :: (C a, C b) => b -> a -> aSource

A prefix function of '(Algebra.Ring.^)' with a parameter order that fits the needs of partial application and function composition. It has generalised exponent.

See: Argument order of expNat on

fieldPower :: (C a, C b) => b -> a -> aSource

A prefix function of '(Algebra.Field.^-)'. It has a generalised exponent.