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

LicenseBSD-style
Maintainerjcpetruzza@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

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 -> Hash Source

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 Source

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