hash package:hashable

Like hashWithSalt, but no salt is used. The default implementation uses hashWithSalt with some default salt. Instances might want to implement this method to provide a more efficient implementation than the default implementation.
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. Hashable is intended exclusively for use in in-memory data structures. Hashable does not 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, hashable is not recommended for use other than in-memory datastructures. Specifically, hashable is not intended for network use or in applications which persist hashed values. For stable hashing use named hashes: sha256, crc32, xxhash etc.
Compute a hash value for the content of this ByteArray#, beginning at the specified offset, using specified number of bytes.
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.
Compute a hash value for the content of this pointer.
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.
Transform a value into a Hashable 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 Hashable. Example:
data Foo = Foo | Bar
deriving (Enum)

instance Hashable Foo where
hashWithSalt = hashUsing fromEnum
Return a hash value for the argument, using the given salt. The general contract of hashWithSalt is:
  • If two values are equal according to the == method, then applying the hashWithSalt method on each of the two values must produce the same integer result if the same salt is used in each case.
  • It is not required that if two values are unequal according to the == method, then applying the hashWithSalt 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.
  • 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 hashWithSalt must make use of the salt in its implementation.
  • hashWithSalt may return negative Int values.
Return a hash value for the argument, using the given salt. The general contract of hashWithSalt is:
  • If two values are equal according to the == method, then applying the hashWithSalt method on each of the two values must produce the same integer result if the same salt is used in each case.
  • It is not required that if two values are unequal according to the == method, then applying the hashWithSalt 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.
  • 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 hashWithSalt must make use of the salt in its implementation.
  • hashWithSalt may return negative Int values.
Wrap a hashable value, caching the hash function result.
hash has Eq requirement.
Lift the hashWithSalt function through the type constructor.
hashWithSalt1 = liftHashWithSalt hashWithSalt
Lift the hashWithSalt function through the type constructor.
hashWithSalt2 = liftHashWithSalt2 hashWithSalt hashWithSalt
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.4 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
The class of types that can be converted to a hash value. Minimal implementation: hashWithSalt. Hashable is intended exclusively for use in in-memory data structures. . Hashable does not 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, Hashable is not recommended for use other than in-memory datastructures. Specifically, Hashable 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 Hashable instance in time package, check time-compat
A hashable value along with the result of the hash function.
Default implementation of hash based on hashWithSalt.
Since we support a generic implementation of hashWithSalt we cannot also provide a default implementation for that method for the non-generic instance use case. Instead we provide defaultHashWith.
Hashed cannot be Functor
Hashed cannot be Traversable
Unwrap hashed value.
The class of types that can be generically hashed.
Generic hashWithSalt.