Commits

Bryan O'Sullivan  committed d497e6d

Add freeze, re-export others

  • Participants
  • Parent commits b513a32

Comments (0)

Files changed (1)

File Data/BloomFilter.hs

     , MBloom
 
     -- * Immutable Bloom filters
+
+    -- ** Conversion
+    , freeze
+    , thaw
+    , unsafeFreeze
+
     -- ** Creation
     , unfold
 
     , elem
     , notElem
 
-    -- ** Mutators
+    -- ** Modification
     , insert
     , insertList
 
   unsafeFreeze mb
 
 -- | Create an immutable Bloom filter from a mutable one.  The mutable
+-- filter may be modified afterwards.
+freeze :: MBloom s a -> ST s (Bloom a)
+freeze mb = B (MB.hashes mb) (MB.shift mb) (MB.mask mb) `liftM`
+            ST.freeze (MB.bitArray mb)
+
+-- | Create an immutable Bloom filter from a mutable one.  The mutable
 -- filter /must not/ be modified afterwards, or a runtime crash may
--- occur.  For a safer creation interface, use 'create'.
+-- occur.  For a safer creation interface, use 'freeze' or 'create'.
 unsafeFreeze :: MBloom s a -> ST s (Bloom a)
 unsafeFreeze mb = B (MB.hashes mb) (MB.shift mb) (MB.mask mb) `liftM`
                     ST.unsafeFreeze (MB.bitArray mb)