non-negative 0.0.3 → 0.0.4
raw patch · 3 files changed
+23/−8 lines, 3 filesdep ~QuickCheck
Dependency ranges changed: QuickCheck
Files
- non-negative.cabal +4/−3
- src/Numeric/NonNegative/Chunky.hs +1/−2
- src/Numeric/NonNegative/ChunkyPrivate.hs +18/−3
non-negative.cabal view
@@ -1,5 +1,5 @@ Name: non-negative-Version: 0.0.3+Version: 0.0.4 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -25,10 +25,11 @@ default: False Library+ Build-Depends: QuickCheck >= 1.0 && <2 If flag(splitBase)- Build-Depends: base >= 2, QuickCheck+ Build-Depends: base >= 2 Else- Build-Depends: base >= 1.0 && < 2, QuickCheck+ Build-Depends: base >= 1.0 && < 2 GHC-Options: -Wall Hs-Source-Dirs: src
src/Numeric/NonNegative/Chunky.hs view
@@ -16,7 +16,6 @@ which allows for co-recursive merges. -} module Numeric.NonNegative.Chunky- (T, fromChunks, fromNumber, toNumber, normalize, isNull, isPositive, ) where+ (T, fromChunks, fromNumber, toChunks, toNumber, zero, normalize, isNull, isPositive, ) where import Numeric.NonNegative.ChunkyPrivate- (T, fromChunks, fromNumber, toNumber, normalize, isNull, isPositive, )
src/Numeric/NonNegative/ChunkyPrivate.hs view
@@ -11,7 +11,8 @@ we cannot use that in the NumericPrelude. -} module Numeric.NonNegative.ChunkyPrivate- (T, fromChunks, fromNumber, toNumber, normalize, isNull, isPositive,+ (T, fromChunks, fromNumber, toChunks, toNumber,+ zero, normalize, isNull, isPositive, fromChunksUnsafe, toChunksUnsafe, ) where import qualified Numeric.NonNegative.Class as NonNeg@@ -40,6 +41,13 @@ fromNumber :: NonNeg.C a => a -> T a fromNumber = fromChunks . (:[]) ++{- |+This routine exposes the inner structure of the lazy number.+-}+toChunks :: T a -> [a]+toChunks = decons+ toNumber :: NonNeg.C a => T a -> a toNumber = sum . decons @@ -53,6 +61,9 @@ lift2 :: ([a] -> [a] -> [a]) -> (T a -> T a -> T a) lift2 f (Cons x) (Cons y) = Cons $ f x y +zero :: T a+zero = Cons []+ {- | Remove zero chunks. -}@@ -154,8 +165,12 @@ fromChunksUnsafe = Cons {- |-This routine exposes the inner structure of the lazy number,-and I think it should be used with care.+This routine exposes the inner structure of the lazy number+and is actually the same as 'toChunks'.+It was considered dangerous,+but you can observe the lazy structure+in tying-the-knot applications anyway.+So the explicit revelation of the chunks seems not to be worse. -} toChunksUnsafe :: T a -> [a] toChunksUnsafe = decons