-- 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, <a>Hashable</a>, 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.
--   
--   <a>Hashable</a> is intended exclusively for use in in-memory data
--   structures.
--   
--   <a>Hashable</a> does <i>not</i> have a fixed standard. This allows it
--   to improve over time.
--   
--   Because it does not have a fixed standard, different computers or
--   computers on different versions of the code will observe different
--   hash values. As such, <a>hashable</a> is not recommended for use other
--   than in-memory datastructures. Specifically, <a>hashable</a> is not
--   intended for network use or in applications which persist hashed
--   values. For stable hashing use named hashes: sha256, crc32, xxhash
--   etc.
@package hashable
@version 1.5.0.0


-- | Lifting of the <a>Hashable</a> 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 (Eq1 t, forall a. Hashable a => Hashable t a) => Hashable1 (t :: Type -> Type)

-- | Lift a hashing function through the type constructor.
liftHashWithSalt :: Hashable1 t => (Int -> a -> Int) -> Int -> t a -> Int
($dmliftHashWithSalt) :: (Hashable1 t, Generic1 t, GHashable One (Rep1 t)) => (Int -> a -> Int) -> Int -> t a -> Int
class (Eq2 t, forall a. Hashable a => Hashable1 t a) => Hashable2 (t :: Type -> Type -> Type)

-- | 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 <a>hashWithSalt</a> function through the type constructor.
--   
--   <pre>
--   hashWithSalt1 = liftHashWithSalt hashWithSalt
--   </pre>
hashWithSalt1 :: (Hashable1 f, Hashable a) => Int -> f a -> Int

-- | Lift the <a>hashWithSalt</a> function through the type constructor.
--   
--   <pre>
--   hashWithSalt2 = liftHashWithSalt2 hashWithSalt hashWithSalt
--   </pre>
hashWithSalt2 :: (Hashable2 f, Hashable a, Hashable b) => Int -> f a b -> Int

-- | Lift the <a>hashWithSalt</a> function halfway through the type
--   constructor. This function makes a suitable default implementation of
--   <a>liftHashWithSalt</a>, given that the type constructor <tt>t</tt> in
--   question can unify with <tt>f a</tt>.
defaultLiftHashWithSalt :: (Hashable2 f, Hashable a) => (Int -> b -> Int) -> Int -> f a b -> Int


-- | Hashable support for GHC generics.
module Data.Hashable.Generic

-- | Generic <a>hashWithSalt</a>.
genericHashWithSalt :: (Generic a, GHashable Zero (Rep a)) => Int -> a -> Int

-- | Generic <a>liftHashWithSalt</a>.
genericLiftHashWithSalt :: (Generic1 t, GHashable One (Rep1 t)) => (Int -> a -> Int) -> Int -> t a -> Int

-- | The class of types that can be generically hashed.
class GHashable arity (f :: Type -> Type)
ghashWithSalt :: GHashable arity f => HashArgs arity a -> Int -> f a -> Int
data One
data Zero
data family HashArgs arity a


-- | This module defines a class, <a>Hashable</a>, 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.4
--   and above.
--   
--   The easiest way to get started is to use the <a>hash</a> function.
--   Here is an example session with <tt>ghci</tt>.
--   
--   <pre>
--   ghci&gt; import Data.Hashable
--   ghci&gt; hash "foo"
--   60853164
--   </pre>
module Data.Hashable

-- | The class of types that can be converted to a hash value.
--   
--   Minimal implementation: <a>hashWithSalt</a>.
--   
--   <a>Hashable</a> is intended exclusively for use in in-memory data
--   structures. . <a>Hashable</a> does <i>not</i> have a fixed standard.
--   This allows it to improve over time. . Because it does not have a
--   fixed standard, different computers or computers on different versions
--   of the code will observe different hash values. As such,
--   <a>Hashable</a> is not recommended for use other than in-memory
--   datastructures. Specifically, <a>Hashable</a> is not intended for
--   network use or in applications which persist hashed values. For stable
--   hashing use named hashes: sha256, crc32, xxhash etc.
--   
--   If you are looking for <a>Hashable</a> instance in <tt>time</tt>
--   package, check <a>time-compat</a>
class Eq a => Hashable a

-- | Return a hash value for the argument, using the given salt.
--   
--   The general contract of <a>hashWithSalt</a> is:
--   
--   <ul>
--   <li>If two values are equal according to the <a>==</a> method, then
--   applying the <a>hashWithSalt</a> method on each of the two values
--   <i>must</i> produce the same integer result if the same salt is used
--   in each case.</li>
--   <li>It is <i>not</i> required that if two values are unequal according
--   to the <a>==</a> method, then applying the <a>hashWithSalt</a> method
--   on each of the two values must produce distinct integer results.
--   However, the programmer should be aware that producing distinct
--   integer results for unequal values may improve the performance of
--   hashing-based data structures.</li>
--   <li>This method can be used to compute different hash values for the
--   same input by providing a different salt in each application of the
--   method. This implies that any instance that defines
--   <a>hashWithSalt</a> <i>must</i> make use of the salt in its
--   implementation.</li>
--   <li><a>hashWithSalt</a> may return negative <a>Int</a> values.</li>
--   </ul>
hashWithSalt :: Hashable a => Int -> a -> Int
($dmhashWithSalt) :: (Hashable a, Generic a, GHashable Zero (Rep a)) => Int -> a -> Int

-- | Like <a>hashWithSalt</a>, but no salt is used. The default
--   implementation uses <a>hashWithSalt</a> with some default salt.
--   Instances might want to implement this method to provide a more
--   efficient implementation than the default implementation.
hash :: Hashable a => a -> Int
infixl 0 `hashWithSalt`

-- | Transform a value into a <a>Hashable</a> value, then hash the
--   transformed value using the given salt.
--   
--   This is a useful shorthand in cases where a type can easily be mapped
--   to another type that is already an instance of <a>Hashable</a>.
--   Example:
--   
--   <pre>
--   data Foo = Foo | Bar
--            deriving (Enum)
--   
--   instance Hashable Foo where
--       hashWithSalt = hashUsing fromEnum
--   </pre>
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 -> Salt -> IO Salt

-- | Compute a hash value for the content of this <a>ByteArray#</a>,
--   beginning at the specified offset, using specified number of bytes.
hashByteArray :: ByteArray# -> Int -> Int -> Int

-- | Compute a hash value for the content of this <a>ByteArray#</a>, 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 -> Salt -> Salt

-- | Since we support a generic implementation of <a>hashWithSalt</a> we
--   cannot also provide a default implementation for that method for the
--   non-generic instance use case. Instead we provide
--   <tt>defaultHashWith</tt>.
defaultHashWithSalt :: Hashable a => Int -> a -> Int

-- | Default implementation of <a>hash</a> based on <a>hashWithSalt</a>.
defaultHash :: Hashable a => a -> Int

-- | A hashable value along with the result of the <a>hash</a> function.
data Hashed a

-- | Wrap a hashable value, caching the <a>hash</a> function result.
hashed :: Hashable a => a -> Hashed a

-- | <a>hash</a> has <a>Eq</a> requirement.
hashedHash :: Hashed a -> Int

-- | Unwrap hashed value.
unhashed :: Hashed a -> a

-- | <a>Hashed</a> cannot be <a>Functor</a>
mapHashed :: Hashable b => (a -> b) -> Hashed a -> Hashed b

-- | <a>Hashed</a> cannot be <a>Traversable</a>
traverseHashed :: (Hashable b, Functor f) => (a -> f b) -> Hashed a -> f (Hashed b)
