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

License | BSD-style
Maintainer | jcpetruzza@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Data.Hash

Contents

- The `Hash` type
  - Basic combinators
  - Derived combinators
- The `Hashable` class
- Rolling hashes

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

- data Hash
- asWord64 :: Hash -> Word64
- hashWord8 :: Word8 -> Hash
- combine :: Hash -> Hash -> Hash
- hashWord16 :: Word16 -> Hash
- hashWord32 :: Word32 -> Hash
- hashWord64 :: Word64 -> Hash
- hashInt :: Int -> Hash
- hashStorable :: Storable a => a -> Hash
- hashFoldable :: (Foldable t, Hashable a) => t a -> Hash
- class Hashable a where
  - hash :: a -> Hash
- module Data.Hash.Rolling

# The `Hash` type

data Hash Source #

A 64-bit hash

#### Instances

Instances details

Bounded Hash Source # |
Instance details Defined in Data.Hash.Base Methods minBound :: Hash Source # maxBound :: Hash Source #
Show Hash Source # |
Instance details Defined in Data.Hash.Base Methods showsPrec :: Int -> Hash -> ShowS Source # show :: Hash -> String Source # showList :: [Hash] -> ShowS Source #
Eq Hash Source # |
Instance details Defined in Data.Hash.Base Methods (==) :: Hash -> Hash -> Bool Source # (/=) :: Hash -> Hash -> Bool Source #
Ord Hash Source # |
Instance details Defined in Data.Hash.Base Methods compare :: Hash -> Hash -> Ordering Source # (<) :: Hash -> Hash -> Bool Source # (<=) :: Hash -> Hash -> Bool Source # (>) :: Hash -> Hash -> Bool Source # (>=) :: Hash -> Hash -> Bool Source # max :: Hash -> Hash -> Hash Source # min :: Hash -> Hash -> Hash Source #

asWord64 :: Hash -> Word64 Source #

## Basic combinators

hashWord8 :: Word8 -> Hash Source #

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

hashWord16 :: Word16 -> Hash Source #

hashWord32 :: Word32 -> Hash Source #

hashWord64 :: Word64 -> Hash Source #

hashInt :: Int -> Hash Source #

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.).

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

# The `Hashable` class

class Hashable a where Source #

Methods

hash :: a -> Hash Source #

#### Instances

Instances details

Hashable Int16 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Int16 -> Hash Source #
Hashable Int32 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Int32 -> Hash Source #
Hashable Int64 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Int64 -> Hash Source #
Hashable Int8 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Int8 -> Hash Source #
Hashable Word16 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Word16 -> Hash Source #
Hashable Word32 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Word32 -> Hash Source #
Hashable Word64 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Word64 -> Hash Source #
Hashable Word8 Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Word8 -> Hash Source #
Hashable Integer Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Integer -> Hash Source #
Hashable () Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: () -> Hash Source #
Hashable Bool Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Bool -> Hash Source #
Hashable Char Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Char -> Hash Source #
Hashable Double Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Double -> Hash Source #
Hashable Float Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Float -> Hash Source #
Hashable Int Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Int -> Hash Source #
Hashable Word Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Word -> Hash Source #
(Integral a, Hashable a) => Hashable (Ratio a) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Ratio a -> Hash Source #
Hashable a => Hashable (Maybe a) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Maybe a -> Hash Source #
Hashable a => Hashable [a] Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: [a] -> Hash Source #
(Hashable a, Hashable b) => Hashable (Either a b) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: Either a b -> Hash Source #
(Hashable a, Hashable b) => Hashable (a, b) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: (a, b) -> Hash Source #
(Hashable a, Hashable b, Hashable c) => Hashable (a, b, c) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: (a, b, c) -> Hash Source #
(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a, b, c, d) Source # |
Instance details Defined in Data.Hash.Instances Methods hash :: (a, b, c, d) -> Hash Source #

# Rolling hashes

module Data.Hash.Rolling