Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Data.Number.Peano
Description
Value-level Peano arithmetic.
Documentation
Lazy Peano numbers. Allow calculation with infinite values.
Instances
Bounded Nat Source | The lower bound is zero, the upper bound is infinity. |
Enum Nat Source | The |
Eq Nat Source | |
Integral Nat Source | Since negative numbers are not allowed,
n |
Num Nat Source | 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 Source | All methods work as long as at least one operand is finite. |
Real Nat Source | Since |
Show Nat Source | |
Peano Nat Source | Peano class instance |
Sign for whole numbers.
Whole numbers (Z).
Instances
Bounded Whole Source | The bounds are negative and positive infinity. |
Enum Whole Source |
|
Eq Whole Source | Positive and negative zero are considered equal. |
Integral Whole Source | Integer conversions and division |
Num Whole Source | Implements arithmetics for Whole numbers |
Ord Whole Source | The ordering is the standard total order on Z. Positive and negative zero are equal. |
Real Whole Source | Since |
Peano Whole Source | Peano class instance defines infinity (positive) and other functions handling the sign |
class Enum a => Peano a where Source
The class of Peano-like constructions (i.e. Nat and Whole).
Methods
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.