-- 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. All functions are supposed to be as non-strict as -- possible. Furthermore the implementation is supposed to be 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.2 -- | 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.Nat1 -- | A binary representation of natural numbers which starts with the least -- significant bit. data Nat1 -- | This constructor represents the most significant bit. There are no -- leading zero bits. IHi :: Nat1 -- | A zero bit O :: Nat1 -> Nat1 -- | A one bit I :: Nat1 -> Nat1 -- | 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. cmpNat1LT :: Nat1 -> Nat1 -> Ordering -- | Maps LT to GT and GT to LT. It is used instead of defining a function -- cmpNat1GT. invOrd :: Ordering -> Ordering -- | minusNat1 x y yields x - y + 1. This is used to implement (-) for -- natural numbers. minusNat1 :: Nat1 -> Nat1 -> Nat1 -- | This is used for the implementation of toInteger and fromEnum. fromNat1 :: Num n => Nat1 -> n -- | This is used for the implementation of fromInteger and toEnum. toNat1 :: (Integral n, Num n) => n -> Nat1 instance Eq Nat1 instance Real Nat1 instance Num Nat1 instance Enum Nat1 instance Ord Nat1 instance Read Nat1 instance Show Nat1 -- | The implementations of all functions except for rem, quot, div, mod -- are supposed to be as non-strict as possible. module Data.Number.Nat -- | Natural numbers and zero data Nat -- | Constructor representing zero Zero :: Nat -- | A natural number Pos :: Nat1 -> 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 -- | 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 length :: [a] -> Nat take :: Nat -> [a] -> [a] drop :: Nat -> [a] -> [a] replicate :: Nat -> 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] divmodNat1 :: Nat1 -> Nat1 -> (Nat, Nat) instance Eq Nat instance Real Nat instance Integral Nat instance Num Nat instance Enum Nat instance Ord Nat instance Read Nat instance Show Nat -- | 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 :: Nat1 -> Int -- | A positive natural number or zero Pos0 :: Nat -> Int pos :: Nat1 -> 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