    -- |
    -- Module: Data.BloomFilter.Mutable.Internal
    -- Copyright: Bryan O'Sullivan
    -- License: BSD3
    --
    -- Maintainer: Bryan O'Sullivan <bos@serpentine.com>
    -- Stability: unstable
    -- Portability: portable

    module Data.BloomFilter.Mutable.Internal
        (
        -- * Types
          Hash
        , MBloom(..)
        ) where

    import Data.Array.Base (STUArray)
    import Data.Bits (shiftL)
    import Data.Word (Word32)

    import Prelude hiding (elem, length, notElem,
                           (/), (*), div, divMod, mod, rem)

    -- | A hash value is 32 bits wide.  This limits the maximum size of a
    -- filter to about four billion elements, or 512 megabytes of memory.
    type Hash = Word32

    -- | A mutable Bloom filter, for use within the 'ST' monad.
    data MBloom s a = MB {
          forall s a. MBloom s a -> a -> [Hash]
    hashes :: !(a -> [Hash])
        , forall s a. MBloom s a -> Int
    shift :: {-# UNPACK #-} !Int
        , forall s a. MBloom s a -> Int
    mask :: {-# UNPACK #-} !Int
        , forall s a. MBloom s a -> STUArray s Int Hash
    bitArray :: {-# UNPACK #-} !(STUArray s Int Hash)
        }

    instance Show (MBloom s a) where
        show :: MBloom s a -> String
    show MBloom s a
    mb = String
    "MBloom { " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Int -> String
    forall a. Show a => a -> String
    show ((Int
    1::Int) Int -> Int -> Int
    forall a. Bits a => a -> Int -> a
    `shiftL` MBloom s a -> Int
    forall s a. MBloom s a -> Int
    shift MBloom s a
    mb) String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    " bits } "