-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | 32-bit non-cryptographic hashing -- -- MurmurHash is a family of non-cryptographic hash functions suitable -- for general hash-based lookup. This implementation uses the -- MurmurHash3 algorithm and provides a type class for computing 32-bit -- hashes from all prevalent data types in the Haskell 2010 Standard. @package murmurhash3 @version 1.0 -- | For details of the implementation of MurmurHash3, see the following -- webpages: -- --
module Data.Digest.Murmur -- | A 32-bit hash. type Hash = Word32 -- | Computes a 32-bit hash from a hashable value. hash :: Hashable a => a -> Hash -- | Type class for computing hash generators from values. -- -- Making custom data types instantiate Hashable is -- straightforward; given the following tree data structure: -- ---- data Tree a -- = Tip -- | Bin a (Tree a) (Tree a) ---- -- ...we make it instantiate Hashable like this: -- --
-- instance Hashable a => Hashable (Tree a) where -- hashGen Tip = salt 0x0 -- hashGen (Bin x l r) = hashGen x `combine` hashGen l `combine` hashGen r ---- -- For sum data types such as Either we typically want to avoid -- that -- --
-- Left "foo" ---- -- hashes to the same hash as -- --
-- Right "foo" ---- -- ...hence we add some salt for each constructor: -- --
-- instance (Hashable a, Hashable b) => Hashable (Either a b) where -- hashGen (Left x) = salt 0x1 `combine` hashGen x -- hashGen (Right y) = salt 0x2 `combine` hashGen y --class Hashable a hashGen :: Hashable a => a -> HashGen -- | A hash generator is a function that maps a hash state into a new hash -- state. The internal representation of hash states is kept transparent. data HashGen -- | Returns a hash generator that mixes its input with a 32-bit word. Is -- typically used for enumerating constructors when deriving -- Hashable. salt :: Word32 -> HashGen -- | Combines two hash generators such that the output of the first -- generator is piped into the next. This works similar to function -- composition. Indeed, for all f, g, h, we have -- that -- --
-- f `combine` (g `combine` h) == (f `combine` g) `combine` h --combine :: HashGen -> HashGen -> HashGen instance (Hashable a, RealFloat a) => Hashable (Complex a) instance Hashable Double instance Hashable Float instance (Hashable a, Integral a) => Hashable (Ratio a) instance (Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a, b, c, d) instance (Hashable a, Hashable b, Hashable c) => Hashable (a, b, c) instance (Hashable a, Hashable b) => Hashable (a, b) instance (Hashable a, Ix i) => Hashable (Array i a) instance Hashable a => Hashable [a] instance (Hashable a, Hashable b) => Hashable (Either a b) instance Hashable a => Hashable (Maybe a) instance Hashable Bool instance Hashable () instance Hashable Integer instance Hashable Int64 instance Hashable Int32 instance Hashable Int16 instance Hashable Int8 instance Hashable Word64 instance Hashable Word32 instance Hashable Word16 instance Hashable Word8 instance Hashable Int instance Hashable Word instance Hashable Char