-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Lazy binary natural numbers -- -- Implementation of natural numbers and integers by a binary -- representation. The implementation is supposed to be lazy and -- reasonable efficient (in comparison to peano numbers). This -- implementation is inspired by a similar approach in the functional -- logic programming language Curry. @package nat @version 0.1 -- | The implementations of all functions are supposed to be as non-strict -- as possible. This is non-trivial as for example a naive implementation -- of (*) yields O _|_ for the application I _|_ * O IHi while a -- least-strict version yields O (I _|_). Also the naive / standard -- implementations of (-), compare, (<), (<=), (>), (>=) are -- more strict than necessary. module Data.Number.Nat -- | A binary representation of natural numbers which starts with the least -- significant bit. data Nat -- | This constructor represents the most significant bit. There are no -- leading zero bits. IHi :: Nat -- | A zero bit O :: Nat -> Nat -- | A one bit I :: Nat -> Nat -- | 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. cmpNatLT :: Nat -> Nat -> Ordering -- | Maps LT to GT and GT to LT. It is used instead of defining a function -- cmpNatGT. invOrd :: Ordering -> Ordering -- | minusNat x y yields x - y + 1. This is used to implement (-) for -- natural numbers. minusNat :: Nat -> Nat -> Nat -- | This is used for the implementation of toInteger and fromEnum. fromNat :: (Num n) => Nat -> n -- | This is used for the implementation of fromInteger and toEnum. toNat :: (Integral n, Num n) => n -> Nat instance Show Nat instance Eq Nat instance Real Nat instance Num Nat instance Enum Nat instance Ord Nat instance Read Nat -- | The implementations of all functions except for rem, quot, div, mod -- are supposed to be as non-strict as possible. module Data.Number.NatO -- | Natural numbers and zero data NatO -- | Constructor representing zero Zero :: NatO -- | A natural number Nat :: Nat -> NatO -- | 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. cmpNatOLT :: NatO -> NatO -> Ordering -- | This is used for the implementation of toInteger and fromEnum. fromNatO :: (Num n) => NatO -> n -- | This is used for the implementation of fromInteger and toEnum. toNatO :: (Integral n, Num n) => n -> NatO length :: [a] -> NatO take :: NatO -> [a] -> [a] drop :: NatO -> [a] -> [a] replicate :: NatO -> a -> [a] lengthNum :: (Enum n, Num n) => [a] -> n takeNum :: (Enum n, Num n) => n -> [a] -> [a] dropNum :: (Enum n, Num n) => n -> [a] -> [a] replicateNum :: (Enum n, Num n) => n -> a -> [a] instance Eq NatO instance Real NatO instance Integral NatO instance Num NatO instance Enum NatO instance Ord NatO instance Read NatO instance Show NatO -- | The implementations of all functions except for rem, quot, div, mod -- are supposed to be as non-strict as possible. module Data.Number.Int -- | Integers data Int -- | A negative natural number Neg :: Nat -> Int -- | A positive natural number or zero NatO :: NatO -> Int pos :: Nat -> Int instance Eq Int instance Real Int instance Integral Int instance Num Int instance Enum Int instance Ord Int instance Read Int instance Show Int