Number.NonNegativeChunky
Description
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.
Synopsis
 data T a fromChunks :: C a => [a] -> T a toChunks :: C a => T a -> [a] fromNumber :: C a => a -> T a toNumber :: C a => T a -> a fromChunky98 :: (C a, C a) => T a -> T a toChunky98 :: (C a, C a) => T a -> T a minMaxDiff :: C a => T a -> T a -> (T a, T a, Bool) normalize :: C a => T a -> T a isNull :: C a => T a -> Bool isPositive :: C a => T a -> Bool
Documentation
 data T a Source

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.

The type is equivalent to Numeric.NonNegative.Chunky.

Instances
 C a => Eq (T a) (C a, Eq a, Show a, C a) => Fractional (T a) (C a, Eq a, Show a, C a) => Num (T a) C a => Ord (T a) Show a => Show (T a) (C a, Arbitrary a) => Arbitrary (T a) C a => Monoid (T a) C a => C (T a) (C a, C a) => C (T a) C a => C (T a) C a => C (T a) (Ord a, C a, C a) => C (T a) (C a, C a, C a) => C (T a) C a => C (T a) (C a, C a) => C (T a) (C a, C a) => C (T a) (C a, C a) => C (T a)
 fromChunks :: C a => [a] -> T a Source
 toChunks :: C a => T a -> [a] Source
 fromNumber :: C a => a -> T a Source
 toNumber :: C a => T a -> a Source
 fromChunky98 :: (C a, C a) => T a -> T a Source
 toChunky98 :: (C a, C a) => T a -> T a Source
 minMaxDiff :: C a => T a -> T a -> (T a, T a, Bool) Source
In minMaxDiff x y == (z,r,b) z represents min x y, r represents max x y - min x y, and xy ==> b@ or @x>y == not b, for x==y the value of b is arbitrary.
 normalize :: C a => T a -> T a Source
Remove zero chunks.
 isNull :: C a => T a -> Bool Source
 isPositive :: C a => T a -> Bool Source