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.
- data T a
- fromChunks :: C a => [a] -> T a
- fromNumber :: C a => a -> T a
- toChunks :: T a -> [a]
- toNumber :: C a => T a -> a
- zero :: T a
- normalize :: C a => T a -> T a
- isNull :: C a => T a -> Bool
- isPositive :: C a => T a -> Bool
- minMaxDiff :: C a => T a -> T a -> (T a, T a, Bool)
- divModStrict :: (Integral a, C a) => T a -> a -> (T a, a)
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.
let y = min (1+y) 2 in y is defined,
let y = min (y+1) 2 in y is not.
minMaxDiff x y == (z,r,b)
min x y,
max x y - min x y,
xy == b or
x>y ==> not b,
x==y the value of b is arbitrary.