packages feed

peano-inf 0.2 → 0.3

raw patch · 2 files changed

+36/−18 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Number.Peano.Inf: Succ :: Nat -> Nat
- Number.Peano.Inf: Zero :: Nat
- Number.Peano.Inf: isInfinity :: Nat -> Bool

Files

Number/Peano/Inf.hs view
@@ -5,11 +5,35 @@ Portability  :   portable  Lazy Peano numbers including observable infinity value.++Note that the following equation does /not/ hold for this number type:++* @1 + a > a@,  because @1 + infinity == infinity@.++The following operation is undefined:++* @infinity - infinity@++There are variants of @(-)@ with different behaviour regarding this, see below.++The following operations are naturally undefined:++* @fromEnum infinity@++* @toInteger infinity@++* @0 - n@, if @n > 0@++* @fromInteger n@, if @n < 0@++* @toEnum n@, if @n < 0@++* @pred 0@+ -} module Number.Peano.Inf-    ( Nat (Zero, Succ)+    ( Nat     , infinity-    , isInfinity     , diff     , zeroDiff     , infDiff@@ -29,18 +53,12 @@ infinity :: Nat infinity = Inf --- | True on @(infinity)@, @(5 + 4 * infinity)@ etc. Evaluates to bottom on @(genericLength [1..])@. -isInfinity :: Nat -> Bool-isInfinity Zero = False-isInfinity Inf  = True-isInfinity (Succ n) = isInfinity n- instance Eq Nat where      Zero   == Zero   = True     Succ n == Succ m = n == m-    Inf    == Inf    = error "Number.Peano.Inf: infinity == infinity."+    Inf    == Inf    = True     Succ n == Inf    = n == Inf      Inf    == Succ m = Inf == m      _      == _      = False@@ -51,14 +69,14 @@     Zero   `compare` _      = LT     _      `compare` Zero   = GT     Succ n `compare` Succ m = n `compare` m-    Inf    `compare` Inf    = error "Number.Peano.Inf: infinity `compare` infinity."+    Inf    `compare` Inf    = EQ     Inf    `compare` Succ m = Inf `compare` m     Succ n `compare` Inf    = n `compare` Inf      _      < Zero   = False     Zero   < _      = True     Succ n < Succ m = n < m-    Inf    < Inf    = error "Number.Peano.Inf: infinity < infinity."+    Inf    < Inf    = False     Inf    < Succ m = Inf < m     Succ n < Inf    = n < Inf @@ -108,7 +126,7 @@ Succ n `diff` Inf    = n `diff` Inf  --- | Variant of @diff@: @infinity `infDiff` infinity  ==  Left infinity@.+-- | Variant of @diff@: @infDiff infinity infinity  ==  Left infinity@. infDiff     :: Nat             -- ^ n     -> Nat             -- ^ m@@ -121,7 +139,7 @@ Zero   `infDiff` m      = Right m  --- | Variant of @diff@: @infinity `zeroDiff` infinity  ==  Left Zero@.+-- | Variant of @diff@: @zeroDiff infinity infinity  ==  Left 0@. zeroDiff     :: Nat             -- ^ n     -> Nat             -- ^ m@@ -210,11 +228,11 @@         Left Zero -> n: repeat n'          -- decreasing sequence-        Left d -> case m `zeroDiff` n of+        Left d -> case m `compare` n of -            Left Zero -> [n]-            Left _    -> []-            Right k   -> n: f (n' `zeroDiff` m) n'  where    -- n' >= m ?    n'-m = (-(m-n)) - (n-n'),  if n,m < inf+            EQ  -> [n]+            GT  -> []+            LT  -> n: f (n' `zeroDiff` m) n'  where    -- n' >= m ?    n'-m = (-(m-n)) - (n-n'),  if n,m < inf                  f (Right _) _                 = []                 f (Left j)  l                 = l: f (j `zeroDiff` d) (l - d)
peano-inf.cabal view
@@ -1,5 +1,5 @@ name:           peano-inf-version:        0.2+version:        0.3 synopsis:       Lazy Peano numbers including observable infinity value. description:         Lazy Peano numbers including observable infinity value.