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

Portabilityportable
Stabilityexperimental
Maintainerjcpetruzza@gmail.com
Safe HaskellSafe-Infered

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 Source

A 64-bit hash

Basic combinators

combine :: Hash -> Hash -> HashSource

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 -> HashSource

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

The Hashable class

Rolling hashes