packages feed

hash 0.1.2 → 0.2

raw patch · 4 files changed

+10/−91 lines, 4 filesdep ~hashable

Dependency ranges changed: hashable

Files

README.markdown view
@@ -1,7 +1,7 @@ hash ==== -[![Build Status](https://secure.travis-ci.org/ekmett/hash.png?branch=master)](http://travis-ci.org/ekmett/hash)+[![Build Status](https://secure.travis-ci.org/analytics/hash.png?branch=master)](http://travis-ci.org/analytics/hash)  This package provides a bunch of hashing machinery. 
hash.cabal view
@@ -1,6 +1,6 @@ name:          hash category:      Data, Hash-version:       0.1.2+version:       0.2 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -52,7 +52,6 @@     transformers     >= 0.2      && < 0.4    exposed-modules:-    Data.Hashable.Extras     Data.Hash.CRC32     Data.Hash.Double     Data.Hash.Rolling
src/Data/Hash/CRC32.hs view
@@ -4,6 +4,10 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ForeignFunctionInterface #-}++#ifndef MIN_VERSION_lens+#define MIN_VERSION_lens(x,y,z) 1+#endif -------------------------------------------------------------------- -- | -- Copyright :  (c) Edward Kmett 2013@@ -42,7 +46,11 @@   _Snoc = unto $ \(CRC32 h, w) -> CRC32 (shiftL h 8 `xor` lut w)   {-# INLINE _Snoc #-} +#if MIN_VERSION_lens(3,9,0) updated :: Getting (Endo (Endo CRC32)) t Word8 -> t -> CRC32 -> CRC32+#else+updated :: Getting (Endo (Endo CRC32)) t t Word8 Word8 -> t -> CRC32 -> CRC32+#endif updated l t z = foldlOf' l snoc z t {-# INLINE updated #-} 
− src/Data/Hashable/Extras.hs
@@ -1,88 +0,0 @@-{-# LANGUAGE DefaultSignatures #-}------------------------------------------------------------------------ |--- Copyright :  (c) Edward Kmett 2013--- License   :  BSD3--- Maintainer:  Edward Kmett <ekmett@gmail.com>--- Stability :  experimental--- Portability: non-portable-------------------------------------------------------------------------module Data.Hashable.Extras-  ( Hashable1(..)-  , Hashable2(..)-  , Hashed(..)-  , hashWith1-  , hashWith2-  , salt-  ) where--import Data.Bifunctor-import Data.Functor.Identity-import Data.Hashable--data Hashed = Hashed { unhashed :: Int -> Int }--instance Hashable Hashed where-  hashWithSalt n f = unhashed f n-  {-# INLINE hashWithSalt #-}--data Salt = Salt--instance Hashable Salt where-  hashWithSalt = const-  {-# INLINE hashWithSalt #-}---- | Extract the default salt used by `Data.Hashable`-salt :: Int-salt = hash Salt--class Hashable1 t where-  hashWithSalt1 :: Hashable a => Int -> t a -> Int-  default hashWithSalt1 :: (Hashable a, Hashable (t a)) => Int -> t a -> Int-  hashWithSalt1 = hashWithSalt1-  {-# INLINE hashWithSalt1 #-}--  hash1 :: Hashable a => t a -> Int-  hash1 = hashWithSalt1 salt-  {-# INLINE hash1 #-}--instance Hashable1 Identity where-  hashWithSalt1 n (Identity a) = hashWithSalt n a-  {-# INLINE hashWithSalt1 #-}--instance Hashable1 Maybe-instance Hashable1 []-instance Hashable a => Hashable1 (Either a)-instance Hashable a => Hashable1 ((,) a)-instance (Hashable a, Hashable b) => Hashable1 ((,,) a b)-instance (Hashable a, Hashable b, Hashable c) => Hashable1 ((,,,) a b c)-instance (Hashable a, Hashable b, Hashable c, Hashable d) => Hashable1 ((,,,,) a b c d)-instance (Hashable a, Hashable b, Hashable c, Hashable d, Hashable e) => Hashable1 ((,,,,,) a b c d e)-instance (Hashable a, Hashable b, Hashable c, Hashable d, Hashable e, Hashable f) => Hashable1 ((,,,,,,) a b c d e f)--class Hashable2 t where-  hashWithSalt2 :: (Hashable a, Hashable b) => Int -> t a b -> Int-  default hashWithSalt2 :: (Hashable a, Hashable b, Hashable (t a b)) => Int -> t a b -> Int-  hashWithSalt2 = hashWithSalt-  {-# INLINE hashWithSalt2 #-}--  hash2 :: (Hashable a, Hashable b) => t a b -> Int-  hash2 = hashWithSalt2 salt-  {-# INLINE hash2 #-}--instance Hashable2 Either-instance Hashable2 (,)-instance Hashable a => Hashable2 ((,,) a)-instance (Hashable a, Hashable b) => Hashable2 ((,,,) a b)-instance (Hashable a, Hashable b, Hashable c) => Hashable2 ((,,,,) a b c)-instance (Hashable a, Hashable b, Hashable c, Hashable d) => Hashable2 ((,,,,,) a b c d)-instance (Hashable a, Hashable b, Hashable c, Hashable d, Hashable e) => Hashable2 ((,,,,,,) a b c d e)--hashWith1 :: (Functor t, Hashable1 t) => (Int -> a -> Int) -> Int -> t a -> Int-hashWith1 h s ta = s `hashWithSalt1` fmap (\a -> Hashed (`h` a)) ta-{-# INLINE hashWith1 #-}--hashWith2 :: (Bifunctor t, Hashable2 t) => (Int -> a -> Int) -> (Int -> b -> Int) -> Int -> t a b -> Int-hashWith2 h1 h2 s tab = s `hashWithSalt2` bimap (\a -> Hashed (`h1` a)) (\b -> Hashed (`h2` b)) tab-{-# INLINE hashWith2 #-}