packages feed

bloomfilter 1.2.4 → 1.2.5

raw patch · 2 files changed

+21/−9 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.BloomFilter.Easy: safeSuggestSizing :: Int -> Double -> Either String (Int, Int)

Files

Data/BloomFilter/Easy.hs view
@@ -24,6 +24,7 @@     -- $example      -- * Useful defaults for creation+    , safeSuggestSizing     , suggestSizing     ) where @@ -57,18 +58,29 @@ -- filter should return @True@ when an element is not actually -- present.  It should be a fraction between 0 and 1, so a 1% false -- positive rate is represented by 0.01.-suggestSizing :: Int            -- ^ expected maximum capacity-              -> Double         -- ^ desired false positive rate (0 < /e/ < 1)-              -> (Int, Int)-suggestSizing capacity errRate-    | capacity <= 0                = fatal "invalid capacity"-    | errRate <= 0 || errRate >= 1 = fatal "invalid error rate"+safeSuggestSizing+    :: Int              -- ^ expected maximum capacity+    -> Double           -- ^ desired false positive rate (0 < /e/ < 1)+    -> Either String (Int, Int)+safeSuggestSizing capacity errRate+    | capacity <= 0                = Left "invalid capacity"+    | errRate <= 0 || errRate >= 1 = Left "invalid error rate"     | otherwise =     let cap = fromIntegral capacity         (bits :: Double, hashes :: Double) =             minimum [((-k) * cap / log (1 - (errRate ** (1 / k))), k)                      | k <- [1..100]]-    in (nextPowerOfTwo (ceiling bits), truncate hashes)+        roundedBits = nextPowerOfTwo (ceiling bits)+    in if roundedBits <= 0+       then Left  "capacity too large to represent"+       else Right (roundedBits, truncate hashes)++-- | Behaves as 'safeSuggestSizing', but calls 'error' if given+-- invalid or out-of-range inputs.+suggestSizing :: Int            -- ^ expected maximum capacity+              -> Double         -- ^ desired false positive rate (0 < /e/ < 1)+              -> (Int, Int)+suggestSizing cap errs = either fatal id (safeSuggestSizing cap errs)   where fatal = error . ("Data.BloomFilter.Util.suggestSizing: " ++)  -- $example
bloomfilter.cabal view
@@ -1,5 +1,5 @@ name:            bloomfilter-version:         1.2.4+version:         1.2.5 license:         BSD3 license-file:    LICENSE author:          Bryan O'Sullivan <bos@serpentine.com>@@ -11,7 +11,7 @@ stability:       provisional build-type:      Simple cabal-version:   >= 1.2-tested-with:     GHC ==6.8.2+tested-with:     GHC ==6.8.3 extra-source-files: README cbits/lookup3.c cbits/lookup3.h                  examples/Makefile examples/SpellChecker.hs examples/Words.hs