data-hash-0.1.0.0: Combinators for building fast hashing functions.

Portabilityportable
Stabilityexperimental
Maintainerjcpetruzza@gmail.com
Safe HaskellNone

Data.Hash

Contents

Description

Combinators for building fast hashing functions.

Based on the BuzHash algorithm by Robert Uzgalis (see, e.g. "Hashing concepts and the Java programming language" at http://www.serve.net/buz/hash.adt/java.000.html)

Synopsis

The Hash type

data Hash

A 64-bit hash

Basic combinators

combine :: Hash -> Hash -> Hash

h1 `combine` h2 combines hashes h1 and h2 into a new hash.

It is used to generate hash functions for complex types. For example:

 hashPair :: (Hashable a, Hashable b) => (a,b) -> Hash
 hashPair (a,b) = hash a `combine` hash b

Derived combinators

hashStorable :: Storable a => a -> Hash

Observe that, unlike the other functions in this module, hashStorable is machine-dependent (the computed hash depends on endianness, etc.).

hashFoldable :: (Foldable t, Hashable a) => t a -> Hash

The Hashable class