packages feed

papa-0.7.0: src/Papa/Hashable/Data/Hashable.hs

{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}

-- | Hashing: the class of the keys of 'Data.HashMap.Strict.HashMap' and the
-- elements of 'Data.HashSet.HashSet', and values cached with their hashes.
--
-- Not exported: @hashPtr@, @hashPtrWithSalt@, @hashByteArray@ and
-- @hashByteArrayWithSalt@, which read the memory at a pointer or an offset
-- that they do not check, outside the value for a bad length.
module Papa.Hashable.Data.Hashable (
  module X,
) where

import Data.Hashable as X hiding (
  hashByteArray,
  hashByteArrayWithSalt,
  hashPtr,
  hashPtrWithSalt,
 )

-- $setup
-- >>> :set -XNoImplicitPrelude
-- >>> import Papa
-- >>> import Papa.Hashable.Data.Hashable
-- >>> import Hedgehog
-- >>> import qualified Hedgehog.Gen as Gen
-- >>> import qualified Hedgehog.Range as Range

-- $examples
--
-- ==== __Examples__
--
-- >>> unhashed (hashed "papa")
-- "papa"
--
-- >>> check $ withTests 100 $ property $ do a <- forAll (Gen.int (Range.linear 0 100)); b <- forAll (Gen.int (Range.linear 0 100)); (a == b) === (a == b && hash a == hash b)
-- ...passed 100 tests.
-- True
--
-- >>> check $ withTests 100 $ property $ do a <- forAll (Gen.string (Range.linear 0 10) Gen.alpha); hashedHash (hashed a) === hash a
-- ...passed 100 tests.
-- True