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

Instances

Bounded Hash Source # 
Eq Hash Source # 

Methods

(==) :: Hash -> Hash -> Bool #

(/=) :: Hash -> Hash -> Bool #

Ord Hash Source # 

Methods

compare :: Hash -> Hash -> Ordering #

(<) :: Hash -> Hash -> Bool #

(<=) :: Hash -> Hash -> Bool #

(>) :: Hash -> Hash -> Bool #

(>=) :: Hash -> Hash -> Bool #

max :: Hash -> Hash -> Hash #

min :: Hash -> Hash -> Hash #

Show Hash Source # 

Methods

showsPrec :: Int -> Hash -> ShowS #

show :: Hash -> String #

showList :: [Hash] -> ShowS #

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

class Hashable a where Source #

Minimal complete definition

hash

Methods

hash :: a -> Hash Source #

Instances

Hashable Bool Source # 

Methods

hash :: Bool -> Hash Source #

Hashable Char Source # 

Methods

hash :: Char -> Hash Source #

Hashable Double Source # 

Methods

hash :: Double -> Hash Source #

Hashable Float Source # 

Methods

hash :: Float -> Hash Source #

Hashable Int Source # 

Methods

hash :: Int -> Hash Source #

Hashable Int8 Source # 

Methods

hash :: Int8 -> Hash Source #

Hashable Int16 Source # 

Methods

hash :: Int16 -> Hash Source #

Hashable Int32 Source # 

Methods

hash :: Int32 -> Hash Source #

Hashable Int64 Source # 

Methods

hash :: Int64 -> Hash Source #

Hashable Integer Source # 

Methods

hash :: Integer -> Hash Source #

Hashable Word Source # 

Methods

hash :: Word -> Hash Source #

Hashable Word8 Source # 

Methods

hash :: Word8 -> Hash Source #

Hashable Word16 Source # 

Methods

hash :: Word16 -> Hash Source #

Hashable Word32 Source # 

Methods

hash :: Word32 -> Hash Source #

Hashable Word64 Source # 

Methods

hash :: Word64 -> Hash Source #

Hashable () Source # 

Methods

hash :: () -> Hash Source #

Hashable a => Hashable [a] Source # 

Methods

hash :: [a] -> Hash Source #

Hashable a => Hashable (Maybe a) Source # 

Methods

hash :: Maybe a -> Hash Source #

(Integral a, Hashable a) => Hashable (Ratio a) Source # 

Methods

hash :: Ratio a -> Hash Source #

(Hashable a, Hashable b) => Hashable (Either a b) Source # 

Methods

hash :: Either a b -> Hash Source #

(Hashable a, Hashable b) => Hashable (a, b) Source # 

Methods

hash :: (a, b) -> Hash Source #

(Hashable a, Hashable b, Hashable c) => Hashable (a, b, c) Source # 

Methods

hash :: (a, b, c) -> Hash Source #

(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a, b, c, d) Source # 

Methods

hash :: (a, b, c, d) -> Hash Source #

Rolling hashes