exact-pi- Exact rational multiples of pi (and integer powers of pi)

Safe HaskellSafe-Inferred
  • RankNTypes
  • ExplicitForAll



This type is sufficient to exactly express the closure of Q ∪ {π} under multiplication and division. As a result it is useful for representing conversion factors between physical units. Approximate values are included both to close the remainder of the arithmetic operations in the Num typeclass and to encode conversion factors defined experimentally.



data ExactPi Source

Represents an exact or approximate real value. The exactly representable values are rational multiples of an integer power of pi.


Exact Integer Rational

Exact z q = q * pi^z. Note that this means there are many representations of zero.

Approximate (forall a. Floating a => a)

An approximate value. This representation was chosen because it allows conversion to floating types using their native definition of pi.


Floating ExactPi 
Fractional ExactPi 
Num ExactPi 
Show ExactPi 
Monoid ExactPi

The multiplicative monoid over augmented rationals.

Group ExactPi

The multiplicative group over augmented rationals.

Abelian ExactPi 

approximateValue :: Floating a => ExactPi -> a Source

Approximates an exact or approximate value, converting it to a Floating type. This uses the value of pi supplied by the destination type, to provide the appropriate precision.

isExactZero :: ExactPi -> Bool Source

Identifies whether an ExactPi is an exact representation of zero.

isExactOne :: ExactPi -> Bool Source

Identifies whether an ExactPi is an exact representation of one.