2023-03-13 22:39:16 -04:00
|
|
|
{- bloomfilter compatibility wrapper
|
2014-07-07 12:24:12 -04:00
|
|
|
-
|
2015-01-21 12:50:09 -04:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-07-07 12:24:12 -04:00
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Utility.Bloom (
|
|
|
|
Bloom,
|
2014-09-12 12:26:12 -04:00
|
|
|
safeSuggestSizing,
|
2015-06-16 18:37:41 -04:00
|
|
|
Hashable(..),
|
2014-07-07 12:24:12 -04:00
|
|
|
cheapHashes,
|
2015-06-16 18:38:12 -04:00
|
|
|
elemB,
|
2014-07-07 12:24:12 -04:00
|
|
|
notElemB,
|
|
|
|
|
|
|
|
newMB,
|
|
|
|
insertMB,
|
|
|
|
unsafeFreezeMB,
|
|
|
|
) where
|
|
|
|
|
|
|
|
import qualified Data.BloomFilter.Mutable as MBloom
|
|
|
|
import qualified Data.BloomFilter as Bloom
|
2014-09-12 12:26:12 -04:00
|
|
|
import Data.BloomFilter.Easy (safeSuggestSizing, Bloom)
|
2015-06-16 18:37:41 -04:00
|
|
|
import Data.BloomFilter.Hash (Hashable(..), cheapHashes)
|
2015-05-10 14:42:16 -04:00
|
|
|
import Control.Monad.ST (ST)
|
2014-07-07 12:24:12 -04:00
|
|
|
|
|
|
|
notElemB :: a -> Bloom a -> Bool
|
|
|
|
notElemB = Bloom.notElem
|
|
|
|
|
2015-06-16 18:38:12 -04:00
|
|
|
elemB :: a -> Bloom a -> Bool
|
|
|
|
elemB = Bloom.elem
|
|
|
|
|
2014-07-07 12:24:12 -04:00
|
|
|
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
|