nat-0.1: Lazy binary natural numbers




The implementations of all functions except for rem, quot, div, mod are supposed to be as non-strict as possible.



data NatO Source

Natural numbers and zero



Constructor representing zero

Nat Nat

A natural number

Helper Functions

cmpNatOLT :: NatO -> NatO -> OrderingSource

This function is used to implement lazy instances of compare and (<), (<=), (>), (>=). It is used to transfer information to more significant bits. Instead of yielding EQ it yields LT if the numbers are equal.

fromNatO :: Num n => NatO -> nSource

This is used for the implementation of toInteger and fromEnum.

toNatO :: (Integral n, Num n) => n -> NatOSource

This is used for the implementation of fromInteger and toEnum.

Example Implementations using NatO

length :: [a] -> NatOSource

take :: NatO -> [a] -> [a]Source

drop :: NatO -> [a] -> [a]Source

replicate :: NatO -> a -> [a]Source

Example Implementations using Num

lengthNum :: (Enum n, Num n) => [a] -> nSource

takeNum :: (Enum n, Num n) => n -> [a] -> [a]Source

dropNum :: (Enum n, Num n) => n -> [a] -> [a]Source

replicateNum :: (Enum n, Num n) => n -> a -> [a]Source