License | BSD-style |
---|---|
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Data.Hash
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
- module Data.Hash.Rolling
The Hash
type
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
hashWord16 :: Word16 -> Hash Source #
hashWord32 :: Word32 -> Hash Source #
hashWord64 :: Word64 -> 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.).
The Hashable
class
class Hashable a where Source #
Instances
Hashable Int16 Source # | |
Hashable Int32 Source # | |
Hashable Int64 Source # | |
Hashable Int8 Source # | |
Hashable Word16 Source # | |
Hashable Word32 Source # | |
Hashable Word64 Source # | |
Hashable Word8 Source # | |
Hashable Integer Source # | |
Hashable () Source # | |
Defined in Data.Hash.Instances | |
Hashable Bool Source # | |
Hashable Char Source # | |
Hashable Double Source # | |
Hashable Float Source # | |
Hashable Int Source # | |
Hashable Word Source # | |
(Integral a, Hashable a) => Hashable (Ratio a) Source # | |
Hashable a => Hashable (Maybe a) Source # | |
Hashable a => Hashable [a] Source # | |
Defined in Data.Hash.Instances | |
(Hashable a, Hashable b) => Hashable (Either a b) Source # | |
(Hashable a, Hashable b) => Hashable (a, b) Source # | |
Defined in Data.Hash.Instances | |
(Hashable a, Hashable b, Hashable c) => Hashable (a, b, c) Source # | |
Defined in Data.Hash.Instances | |
(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a, b, c, d) Source # | |
Defined in Data.Hash.Instances |
Rolling hashes
module Data.Hash.Rolling