HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulenon-negative-0.1.2Haskell98

Numeric.NonNegative.Chunky

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.

  • 1 type
  • 9 values
newtypenewtype T 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. E.g. let y = min (1+y) 2 in y is defined, let y = min (y+1) 2 in y is not.

Instances11Enum, Eq, Integral, Num, Ord, Real, …
  • (Enum a, C a) => Enum (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • C a => Eq (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • (Integral a, C a) => Integral (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • (C a, Num a) => Num (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • C a => Ord (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • (Real a, C a) => Real (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • Show a => Show (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • Semigroup (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • Monoid (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • (C a, Arbitrary a) => Arbitrary (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate
  • C a => C (T a)Defined in non-negative-0.1.2 · Numeric.NonNegative.ChunkyPrivate

    This instance is not correct with respect to the equality check if the involved numbers contain zero chunks.

valuetoChunks :: T a -> [a]
#

This routine exposes the inner structure of the lazy number.