Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Value-level Peano arithmetic.
Documentation
Lazy Peano numbers. Allow calculation with infinite values.
Bounded Nat | The lower bound is zero, the upper bound is infinity. |
Enum Nat | The |
Eq Nat | |
Integral Nat | Since negative numbers are not allowed,
n |
Num Nat | Addition, multiplication, and subtraction are lazy in both arguments, meaning that, in the case of infinite values, they can produce an infinite stream of S-constructors. As long as the callers of these functions only consume a finite amount of these, the program will not hang.
|
Ord Nat | All methods work as long as at least one operand is finite. |
Real Nat | Since |
Show Nat | |
Peano Nat |
Sign for whole numbers.
Whole numbers (Z).
Bounded Whole | The bounds are negative and positive infinity. |
Enum Whole |
|
Eq Whole | Positive and negative zero are considered equal. |
Num Whole | |
Ord Whole | The ordering is the standard total order on Z. Positive and negative zero are equal. |
Peano Whole |
class Enum a => Peano a where Source
The class of Peano-like constructions (i.e. Nat and Whole).
Test for zero.
An unobservable infinity. For all finite numbers n
, n < infinity
must
hold, but there need not be a total function that tests whether a number
is infinite.
fromPeano :: a -> Integer Source
Converts the number to an Integer.
Reduces the absolute value of the number by 1. If isZero n
, then
decr n = n
and vice versa.