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

Number.Peano

Description

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

Synopsis

Documentation

data T Source

Constructors

 Zero Succ T

Instances

 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

err :: String -> String -> a Source

add :: T -> T -> T Source

sub :: T -> T -> T Source

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

mul :: T -> T -> T Source

fromPosEnum :: (C a, Enum a) => a -> T Source

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

ifLazy :: Bool -> T -> T -> T Source

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. http://www.haskell.org/pipermail/haskell-cafe/2006-October/018753.html

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

On equality the first operand is returned.

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

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

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

On equality the first operand is returned.

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

isAscendingFiniteList :: [T] -> Bool Source

`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

Constructors

 Valuable Fieldscosts :: T value :: a

Instances

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

(&&~) :: Valuable Bool -> Valuable Bool -> Valuable Bool infixr 3 Source

Compute '(&&)' with minimal costs.