diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-07 12:24:12 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-07 12:24:12 -0400 |
commit | b0aa47f30d2224284d65ea3c60de2ba84ded72e4 (patch) | |
tree | b64dbd2a5376cd1dbcae12f0dc7b4488ad7787d1 /Utility/Bloom.hs | |
parent | 8921122d148983af43b0185cec3461f213c6507d (diff) |
Support building with bloomfilter 2.0.0.
Diffstat (limited to 'Utility/Bloom.hs')
-rw-r--r-- | Utility/Bloom.hs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Utility/Bloom.hs b/Utility/Bloom.hs new file mode 100644 index 000000000..e3000de3d --- /dev/null +++ b/Utility/Bloom.hs @@ -0,0 +1,60 @@ +{- bloomfilter compatability wrapper + - + - Copyright 2014 Joey Hess <joey@kitenet.net> + - + - License: BSD-2-clause + -} + +{-# LANGUAGE CPP #-} + +module Utility.Bloom ( + Bloom, + suggestSizing, + Hashable, + cheapHashes, + notElemB, + + newMB, + insertMB, + unsafeFreezeMB, +) where + +#if MIN_VERSION_bloomfilter(2,0,0) +import qualified Data.BloomFilter.Mutable as MBloom +import qualified Data.BloomFilter as Bloom +#else +import qualified Data.BloomFilter as Bloom +#endif +import Data.BloomFilter.Easy (suggestSizing, Bloom) +import Data.BloomFilter.Hash (Hashable, cheapHashes) +import Control.Monad.ST.Safe (ST) + +#if MIN_VERSION_bloomfilter(2,0,0) + +notElemB :: a -> Bloom a -> Bool +notElemB = Bloom.notElem + +newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (MBloom.MBloom s a) +newMB = MBloom.new + +insertMB :: MBloom.MBloom s a -> a -> ST s () +insertMB = MBloom.insert + +unsafeFreezeMB :: MBloom.MBloom s a -> ST s (Bloom a) +unsafeFreezeMB = Bloom.unsafeFreeze + +#else + +notElemB :: a -> Bloom a -> Bool +notElemB = Bloom.notElemB + +newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (Bloom.MBloom s a) +newMB = Bloom.newMB + +insertMB :: Bloom.MBloom s a -> a -> ST s () +insertMB = Bloom.insertMB + +unsafeFreezeMB :: Bloom.MBloom s a -> ST s (Bloom a) +unsafeFreezeMB = Bloom.unsafeFreezeMB + +#endif |