Copyright | (c) Henning Thielemann 2008-2010 |
---|---|
Maintainer | haskell@henning-thielemann.de |
Stability | stable |
Portability | Haskell 98 |
Safe Haskell | Safe |
Language | Haskell98 |
A lazy number type, which is a generalization of lazy Peano numbers.
Comparisons can be made lazy and
thus computations are possible which are impossible with strict number types,
e.g. you can compute let y = min (1+y) 2 in y
.
You can even work with infinite values.
However, depending on the granularity,
the memory consumption is higher than that for strict number types.
This number type is of interest for the merge operation of event lists,
which allows for co-recursive merges.
Documentation
A chunky non-negative number is a list of non-negative numbers. It represents the sum of the list elements. It is possible to represent a finite number with infinitely many chunks by using an infinite number of zeros.
Note the following problems:
Addition is commutative only for finite representations.
E.g. let y = min (1+y) 2 in y
is defined,
let y = min (y+1) 2 in y
is not.
(Enum a, C a) => Enum (T a) Source # | |
C a => Eq (T a) Source # | |
(Integral a, C a) => Integral (T a) Source # | |
(C a, Num a) => Num (T a) Source # | |
C a => Ord (T a) Source # | |
(Real a, C a) => Real (T a) Source # | |
Show a => Show (T a) Source # | |
Monoid (T a) Source # | |
(C a, Arbitrary a) => Arbitrary (T a) Source # | |
C a => C (T a) Source # | This instance is not correct with respect to the equality check if the involved numbers contain zero chunks. |
fromChunks :: C a => [a] -> T a Source #
fromNumber :: C a => a -> T a Source #