foundation-0.0.30: Alternative prelude with batteries and no dependencies

License | BSD-style
Maintainer | Foundation
Safe Haskell | None
Language | Haskell2010

Foundation.Hashing

Contents

- Specific methods

Description

Synopsis

- class Hashable a where
  - hashMix :: Hasher st => a -> st -> st
- class Hasher st
- data FNV1_32
- data FNV1_64
- data FNV1a_32
- data FNV1a_64
- data Sip1_3
- data Sip2_4

# Documentation

class Hashable a where #

Type with the ability to be hashed

Hashable doesn't have any specific rules, and it's made for raw speed. More specifically don't expect different type representing the same data to hash to the same value

    hashMix (1 :: Integer) /= hashMix (1 :: Word8)

True

Methods

hashMix :: Hasher st => a -> st -> st #

#### Instances

Instances details

Hashable Word128 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word128 -> st -> st #
Hashable Word256 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word256 -> st -> st #
Hashable String # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => String -> st -> st #
Hashable IPv4 # |
Instance details Defined in Foundation.Network.IPv4 Methods hashMix :: Hasher st => IPv4 -> st -> st #
Hashable IPv6 # |
Instance details Defined in Foundation.Network.IPv6 Methods hashMix :: Hasher st => IPv6 -> st -> st #
Hashable UUID # |
Instance details Defined in Foundation.UUID Methods hashMix :: Hasher st => UUID -> st -> st #
Hashable Int16 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Int16 -> st -> st #
Hashable Int32 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Int32 -> st -> st #
Hashable Int64 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Int64 -> st -> st #
Hashable Int8 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Int8 -> st -> st #
Hashable Word16 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word16 -> st -> st #
Hashable Word32 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word32 -> st -> st #
Hashable Word64 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word64 -> st -> st #
Hashable Word8 # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Word8 -> st -> st #
Hashable Integer # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Integer -> st -> st #
Hashable Natural # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Natural -> st -> st #
Hashable a => Hashable (Array a) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Array a -> st -> st #
PrimType a => Hashable (UArray a) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => UArray a -> st -> st #
Hashable a => Hashable [a] # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => [a] -> st -> st #
(Hashable a, Hashable b) => Hashable (Tuple2 a b) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Tuple2 a b -> st -> st #
(Hashable a, Hashable b) => Hashable (a, b) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => (a, b) -> st -> st #
(Hashable a, Hashable b, Hashable c) => Hashable (Tuple3 a b c) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Tuple3 a b c -> st -> st #
(Hashable a, Hashable b, Hashable c) => Hashable (a, b, c) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => (a, b, c) -> st -> st #
(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (Tuple4 a b c d) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => Tuple4 a b c d -> st -> st #
(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a, b, c, d) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => (a, b, c, d) -> st -> st #
(Hashable a, Hashable b, Hashable c, Hashable d, Hashable e) => Hashable (a, b, c, d, e) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => (a, b, c, d, e) -> st -> st #
(Hashable a, Hashable b, Hashable c, Hashable d, Hashable e, Hashable f) => Hashable (a, b, c, d, e, f) # |
Instance details Defined in Foundation.Hashing.Hashable Methods hashMix :: Hasher st => (a, b, c, d, e, f) -> st -> st #

class Hasher st #

Incremental Hashing state. Represent an hashing algorithm

the base primitive of this class is `hashMix8`, append mix a Word8 in the state

The class allow to define faster mixing function that works on bigger Word size and any unboxed array of any PrimType elements

Minimal complete definition

hashNew, hashNewParam, hashMix8, hashEnd

#### Instances

Instances details

Hasher FNV1_32 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1_32 hashNewParam :: HashInitParam FNV1_32 -> FNV1_32 hashEnd :: FNV1_32 -> HashResult FNV1_32 hashMix8 :: Word8 -> FNV1_32 -> FNV1_32 hashMix16 :: Word16 -> FNV1_32 -> FNV1_32 hashMix32 :: Word32 -> FNV1_32 -> FNV1_32 hashMix64 :: Word64 -> FNV1_32 -> FNV1_32 hashMixBytes :: PrimType e => UArray e -> FNV1_32 -> FNV1_32
Hasher FNV1_64 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1_64 hashNewParam :: HashInitParam FNV1_64 -> FNV1_64 hashEnd :: FNV1_64 -> HashResult FNV1_64 hashMix8 :: Word8 -> FNV1_64 -> FNV1_64 hashMix16 :: Word16 -> FNV1_64 -> FNV1_64 hashMix32 :: Word32 -> FNV1_64 -> FNV1_64 hashMix64 :: Word64 -> FNV1_64 -> FNV1_64 hashMixBytes :: PrimType e => UArray e -> FNV1_64 -> FNV1_64
Hasher FNV1a_32 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1a_32 hashNewParam :: HashInitParam FNV1a_32 -> FNV1a_32 hashEnd :: FNV1a_32 -> HashResult FNV1a_32 hashMix8 :: Word8 -> FNV1a_32 -> FNV1a_32 hashMix16 :: Word16 -> FNV1a_32 -> FNV1a_32 hashMix32 :: Word32 -> FNV1a_32 -> FNV1a_32 hashMix64 :: Word64 -> FNV1a_32 -> FNV1a_32 hashMixBytes :: PrimType e => UArray e -> FNV1a_32 -> FNV1a_32
Hasher FNV1a_64 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1a_64 hashNewParam :: HashInitParam FNV1a_64 -> FNV1a_64 hashEnd :: FNV1a_64 -> HashResult FNV1a_64 hashMix8 :: Word8 -> FNV1a_64 -> FNV1a_64 hashMix16 :: Word16 -> FNV1a_64 -> FNV1a_64 hashMix32 :: Word32 -> FNV1a_64 -> FNV1a_64 hashMix64 :: Word64 -> FNV1a_64 -> FNV1a_64 hashMixBytes :: PrimType e => UArray e -> FNV1a_64 -> FNV1a_64
Hasher Sip1_3 # |
Instance details Defined in Foundation.Hashing.SipHash Methods hashNew :: Sip1_3 hashNewParam :: HashInitParam Sip1_3 -> Sip1_3 hashEnd :: Sip1_3 -> HashResult Sip1_3 hashMix8 :: Word8 -> Sip1_3 -> Sip1_3 hashMix16 :: Word16 -> Sip1_3 -> Sip1_3 hashMix32 :: Word32 -> Sip1_3 -> Sip1_3 hashMix64 :: Word64 -> Sip1_3 -> Sip1_3 hashMixBytes :: PrimType e => UArray e -> Sip1_3 -> Sip1_3
Hasher Sip2_4 # |
Instance details Defined in Foundation.Hashing.SipHash Methods hashNew :: Sip2_4 hashNewParam :: HashInitParam Sip2_4 -> Sip2_4 hashEnd :: Sip2_4 -> HashResult Sip2_4 hashMix8 :: Word8 -> Sip2_4 -> Sip2_4 hashMix16 :: Word16 -> Sip2_4 -> Sip2_4 hashMix32 :: Word32 -> Sip2_4 -> Sip2_4 hashMix64 :: Word64 -> Sip2_4 -> Sip2_4 hashMixBytes :: PrimType e => UArray e -> Sip2_4 -> Sip2_4

# Specific methods

data FNV1_32 #

FNV1 32 bit state

#### Instances

Instances details

Hasher FNV1_32 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1_32 hashNewParam :: HashInitParam FNV1_32 -> FNV1_32 hashEnd :: FNV1_32 -> HashResult FNV1_32 hashMix8 :: Word8 -> FNV1_32 -> FNV1_32 hashMix16 :: Word16 -> FNV1_32 -> FNV1_32 hashMix32 :: Word32 -> FNV1_32 -> FNV1_32 hashMix64 :: Word64 -> FNV1_32 -> FNV1_32 hashMixBytes :: PrimType e => UArray e -> FNV1_32 -> FNV1_32

data FNV1_64 #

FNV1 64 bit state

#### Instances

Instances details

Hasher FNV1_64 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1_64 hashNewParam :: HashInitParam FNV1_64 -> FNV1_64 hashEnd :: FNV1_64 -> HashResult FNV1_64 hashMix8 :: Word8 -> FNV1_64 -> FNV1_64 hashMix16 :: Word16 -> FNV1_64 -> FNV1_64 hashMix32 :: Word32 -> FNV1_64 -> FNV1_64 hashMix64 :: Word64 -> FNV1_64 -> FNV1_64 hashMixBytes :: PrimType e => UArray e -> FNV1_64 -> FNV1_64

data FNV1a_32 #

FNV1a 32 bit state

#### Instances

Instances details

Hasher FNV1a_32 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1a_32 hashNewParam :: HashInitParam FNV1a_32 -> FNV1a_32 hashEnd :: FNV1a_32 -> HashResult FNV1a_32 hashMix8 :: Word8 -> FNV1a_32 -> FNV1a_32 hashMix16 :: Word16 -> FNV1a_32 -> FNV1a_32 hashMix32 :: Word32 -> FNV1a_32 -> FNV1a_32 hashMix64 :: Word64 -> FNV1a_32 -> FNV1a_32 hashMixBytes :: PrimType e => UArray e -> FNV1a_32 -> FNV1a_32

data FNV1a_64 #

FNV1a 64 bit state

#### Instances

Instances details

Hasher FNV1a_64 # |
Instance details Defined in Foundation.Hashing.FNV Methods hashNew :: FNV1a_64 hashNewParam :: HashInitParam FNV1a_64 -> FNV1a_64 hashEnd :: FNV1a_64 -> HashResult FNV1a_64 hashMix8 :: Word8 -> FNV1a_64 -> FNV1a_64 hashMix16 :: Word16 -> FNV1a_64 -> FNV1a_64 hashMix32 :: Word32 -> FNV1a_64 -> FNV1a_64 hashMix64 :: Word64 -> FNV1a_64 -> FNV1a_64 hashMixBytes :: PrimType e => UArray e -> FNV1a_64 -> FNV1a_64

data Sip1_3 #

Sip State 1-3 (1 compression rounds, 3 digest rounds)

#### Instances

Instances details

Hasher Sip1_3 # |
Instance details Defined in Foundation.Hashing.SipHash Methods hashNew :: Sip1_3 hashNewParam :: HashInitParam Sip1_3 -> Sip1_3 hashEnd :: Sip1_3 -> HashResult Sip1_3 hashMix8 :: Word8 -> Sip1_3 -> Sip1_3 hashMix16 :: Word16 -> Sip1_3 -> Sip1_3 hashMix32 :: Word32 -> Sip1_3 -> Sip1_3 hashMix64 :: Word64 -> Sip1_3 -> Sip1_3 hashMixBytes :: PrimType e => UArray e -> Sip1_3 -> Sip1_3

data Sip2_4 #

Sip State 2-4 (2 compression rounds, 4 digest rounds)

#### Instances

Instances details

Hasher Sip2_4 # |
Instance details Defined in Foundation.Hashing.SipHash Methods hashNew :: Sip2_4 hashNewParam :: HashInitParam Sip2_4 -> Sip2_4 hashEnd :: Sip2_4 -> HashResult Sip2_4 hashMix8 :: Word8 -> Sip2_4 -> Sip2_4 hashMix16 :: Word16 -> Sip2_4 -> Sip2_4 hashMix32 :: Word32 -> Sip2_4 -> Sip2_4 hashMix64 :: Word64 -> Sip2_4 -> Sip2_4 hashMixBytes :: PrimType e => UArray e -> Sip2_4 -> Sip2_4