numeric-prelude-0.4.1: An experimental alternative hierarchy of numeric type classes

Safe HaskellNone



Lazy Peano numbers represent natural numbers inclusive infinity. Since they are lazily evaluated, they are optimally for use as number type of genericLength



data T Source


Succ T 


Bounded T 
Enum T 
Eq T 
Integral T 
Num T 
Ord T 
Read T 
Real T 
Show T 
Ix T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 
C T 

add :: T -> T -> TSource

sub :: T -> T -> TSource

subNeg :: T -> T -> (Bool, T)Source

mul :: T -> T -> TSource

fromPosEnum :: (C a, Enum a) => a -> TSource

toPosEnum :: (C a, Enum a) => T -> aSource

ifLazy :: Bool -> T -> T -> TSource

If all values are completely defined, then it holds

 if b then x else y == ifLazy b x y

However if b is undefined, then it is at least known that the result is larger than min x y.

argMinFull :: (T, a) -> (T, a) -> (T, a)Source

cf. To how to find the shortest list in a list of lists efficiently, this means, also in the presence of infinite lists.

argMin :: (T, a) -> (T, a) -> aSource

On equality the first operand is returned.

argMinimum :: [(T, a)] -> aSource

argMaxFull :: (T, a) -> (T, a) -> (T, a)Source

argMax :: (T, a) -> (T, a) -> aSource

On equality the first operand is returned.

argMaximum :: [(T, a)] -> aSource

isAscendingFiniteList :: [T] -> BoolSource

x0 <= x1 && x1 <= x2 ... for possibly infinite numbers in finite lists.

toListMaybe :: a -> T -> [Maybe a]Source

glue :: T -> T -> (T, (Bool, T))Source

In glue x y == (z,(b,r)) z represents min x y, r represents max x y - min x y, and x<=y == b.

Cf. Numeric.NonNegative.Chunky

data Valuable a Source




costs :: T
value :: a


Eq a => Eq (Valuable a) 
Ord a => Ord (Valuable a) 
Show a => Show (Valuable a) 

(&&~) :: Valuable Bool -> Valuable Bool -> Valuable BoolSource

Compute '(&&)' with minimal costs.