-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A class for types that can be converted to a hash value -- -- This package defines a class, Hashable, for types that can be -- converted to a hash value. This class exists for the benefit of -- hashing-based data structures. The package provides instances for -- basic types and a way to combine hash values. @package hashable @version 1.2.6.1 -- | Lifting of the Hashable class to unary and binary type -- constructors. These classes are needed to express the constraints on -- arguments of types that are parameterized by type constructors. -- Fixed-point data types and monad transformers are such types. module Data.Hashable.Lifted class Hashable1 t where liftHashWithSalt h salt = ghashWithSalt (HashArgs1 h) salt . from1 -- | Lift a hashing function through the type constructor. liftHashWithSalt :: Hashable1 t => (Int -> a -> Int) -> Int -> t a -> Int -- | Lift a hashing function through the type constructor. liftHashWithSalt :: (Hashable1 t, Generic1 t, GHashable One (Rep1 t)) => (Int -> a -> Int) -> Int -> t a -> Int class Hashable2 t -- | Lift a hashing function through the binary type constructor. liftHashWithSalt2 :: Hashable2 t => (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> t a b -> Int -- | Lift the hashWithSalt function through the type constructor. -- --
-- hashWithSalt1 = liftHashWithSalt hashWithSalt --hashWithSalt1 :: (Hashable1 f, Hashable a) => Int -> f a -> Int -- | Lift the hashWithSalt function through the type constructor. -- --
-- hashWithSalt2 = liftHashWithSalt2 hashWithSalt hashWithSalt --hashWithSalt2 :: (Hashable2 f, Hashable a, Hashable b) => Int -> f a b -> Int -- | Lift the hashWithSalt function halfway through the type -- constructor. This function makes a suitable default implementation of -- liftHashWithSalt, given that the type constructor t in -- question can unify with f a. defaultLiftHashWithSalt :: (Hashable2 f, Hashable a) => (Int -> b -> Int) -> Int -> f a b -> Int -- | This module defines a class, Hashable, for types that can be -- converted to a hash value. This class exists for the benefit of -- hashing-based data structures. The module provides instances for most -- standard types. Efficient instances for other types can be generated -- automatically and effortlessly using the generics support in GHC 7.2 -- and above. -- -- The easiest way to get started is to use the hash function. -- Here is an example session with ghci. -- --
-- ghci> import Data.Hashable -- ghci> hash "foo" -- 60853164 --module Data.Hashable -- | The class of types that can be converted to a hash value. -- -- Minimal implementation: hashWithSalt. class Hashable a where hash = hashWithSalt defaultSalt hashWithSalt salt = ghashWithSalt HashArgs0 salt . from -- | Return a hash value for the argument, using the given salt. -- -- The general contract of hashWithSalt is: -- --
-- data Foo = Foo | Bar -- deriving (Enum) -- -- instance Hashable Foo where -- hashWithSalt = hashUsing fromEnum --hashUsing :: (Hashable b) => (a -> b) -> Int -> a -> Int -- | Compute a hash value for the content of this pointer. hashPtr :: Ptr a -> Int -> IO Int -- | Compute a hash value for the content of this pointer, using an initial -- salt. -- -- This function can for example be used to hash non-contiguous segments -- of memory as if they were one contiguous segment, by using the output -- of one hash as the salt for the next. hashPtrWithSalt :: Ptr a -> Int -> Int -> IO Int -- | Compute a hash value for the content of this ByteArray#, -- beginning at the specified offset, using specified number of bytes. hashByteArray :: ByteArray# -> Int -> Int -> Int -- | Compute a hash value for the content of this ByteArray#, using -- an initial salt. -- -- This function can for example be used to hash non-contiguous segments -- of memory as if they were one contiguous segment, by using the output -- of one hash as the salt for the next. hashByteArrayWithSalt :: ByteArray# -> Int -> Int -> Int -> Int -- | A hashable value along with the result of the hash function. data Hashed a -- | Wrap a hashable value, caching the hash function result. hashed :: Hashable a => a -> Hashed a -- | Unwrap hashed value. unhashed :: Hashed a -> a -- | Hashed cannot be Functor mapHashed :: Hashable b => (a -> b) -> Hashed a -> Hashed b -- | Hashed cannot be Traversable traverseHashed :: (Hashable b, Functor f) => (a -> f b) -> Hashed a -> f (Hashed b)