hashable 1.2.2.0 → 1.2.3.0
raw patch · 3 files changed
+68/−3 lines, 3 filesdep ~integer-gmpPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: integer-gmp
API changes (from Hackage documentation)
Files
- CHANGES.md +12/−0
- Data/Hashable/Class.hs +52/−1
- hashable.cabal +4/−2
CHANGES.md view
@@ -1,3 +1,15 @@+## Version 1.2.3.0++ * Silence integer literal overflow warning++ * Add support for GHC 7.10 `integer-gmp2` & `Natural`++ * Add instance for Data.Void++ * Make the SSE .cabal flags manual++ * Add an upper bound on bytestring+ ## Version 1.2.2.0 * Add instances for `Data.ByteString.Short`
Data/Hashable/Class.hs view
@@ -90,8 +90,18 @@ #ifdef VERSION_integer_gmp import GHC.Exts (Int(..)) import GHC.Integer.GMP.Internals (Integer(..))+# if MIN_VERSION_integer_gmp(1,0,0)+import GHC.Exts (sizeofByteArray#)+import GHC.Integer.GMP.Internals (BigNat(BN#))+# endif #endif +#if MIN_VERSION_base(4,8,0)+import Data.Void (Void, absurd)+import GHC.Natural (Natural(..))+import GHC.Exts (Word(..))+#endif+ #include "MachDeps.h" infixl 0 `hashWithSalt`@@ -102,7 +112,7 @@ -- | A default salt used in the implementation of 'hash'. defaultSalt :: Int #if WORD_SIZE_IN_BITS == 64-defaultSalt = 0xdc36d1615b7400a4+defaultSalt = -2578643520546668380 -- 0xdc36d1615b7400a4 #else defaultSalt = 0x087fc72c #endif@@ -241,8 +251,43 @@ hash = fromEnum hashWithSalt = defaultHashWithSalt +#if defined(VERSION_integer_gmp)+# if MIN_VERSION_integer_gmp(1,0,0)+instance Hashable BigNat where+ hashWithSalt salt (BN# ba) = hashByteArrayWithSalt ba 0 numBytes salt+ `hashWithSalt` size+ where+ size = numBytes `quot` SIZEOF_HSWORD+ numBytes = I# (sizeofByteArray# ba)+# endif+#endif++#if MIN_VERSION_base(4,8,0)+instance Hashable Natural where+# if MIN_VERSION_integer_gmp(1,0,0)+ hash (NatS# n) = hash (W# n)+ hash (NatJ# bn) = hash bn++ hashWithSalt salt (NatS# n) = hashWithSalt salt (W# n)+ hashWithSalt salt (NatJ# bn) = hashWithSalt salt bn+# else+ hash (Natural n) = hash n++ hashWithSalt salt (Natural n) = hashWithSalt salt n+# endif+#endif+ instance Hashable Integer where #if defined(VERSION_integer_gmp)+# if MIN_VERSION_integer_gmp(1,0,0)+ hash (S# n) = (I# n)+ hash (Jp# bn) = hash bn+ hash (Jn# bn) = negate (hash bn)++ hashWithSalt salt (S# n) = hashWithSalt salt (I# n)+ hashWithSalt salt (Jp# bn) = hashWithSalt salt bn+ hashWithSalt salt (Jn# bn) = negate (hashWithSalt salt bn)+# else hash (S# int) = I# int hash n@(J# size# byteArray) | n >= minInt && n <= maxInt = fromInteger n :: Int@@ -262,6 +307,7 @@ `hashWithSalt` size where minInt = fromIntegral (minBound :: Int) maxInt = fromIntegral (maxBound :: Int)+# endif #else hashWithSalt salt = foldl' hashWithSalt salt . go where@@ -418,6 +464,11 @@ hash = hashTypeRep hashWithSalt = defaultHashWithSalt {-# INLINE hash #-}++#if MIN_VERSION_base(4,8,0)+instance Hashable Void where+ hashWithSalt _ = absurd+#endif -- | Compute a hash value for the content of this pointer. hashPtr :: Ptr a -- ^ pointer to the data to hash
hashable.cabal view
@@ -1,5 +1,5 @@ Name: hashable-Version: 1.2.2.0+Version: 1.2.3.0 Synopsis: A class for types that can be converted to a hash value Description: This package defines a class, 'Hashable', for types that can be converted to a hash value. This class@@ -29,16 +29,18 @@ Flag sse2 Description: Do we want to assume that a target supports SSE 2? Default: True+ Manual: True Flag sse41 Description: Do we want to assume that a target supports SSE 4.1? Default: False+ Manual: True Library Exposed-modules: Data.Hashable Other-modules: Data.Hashable.Class Build-depends: base >= 4.0 && < 5.0,- bytestring >= 0.9+ bytestring >= 0.9 && < 0.11 if impl(ghc) Build-depends: ghc-prim, text >= 0.11.0.5