HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduledata-hash-0.2.0.1Haskell98

Data.Hash

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)

Contents
  1. The Hash type
  2. Basic combinators
  3. Derived combinators
  4. The Hashable class
  5. Rolling hashes
Synopsis

The Hash type

newtypenewtype Hash

A 64-bit hash

Instances4Bounded, Eq, Ord, Show
  • Bounded HashDefined in data-hash-0.2.0.1 · Data.Hash.Base
  • Eq HashDefined in data-hash-0.2.0.1 · Data.Hash.Base
  • Ord HashDefined in data-hash-0.2.0.1 · Data.Hash.Base
  • Show HashDefined in data-hash-0.2.0.1 · Data.Hash.Base

Basic combinators

valuecombine :: 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

valuehashStorable :: Storable a => a -> Hash

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

The Hashable class

classclass Hashable a where
#

Methods

Instances23Hashable, …

Rolling hashes