hashable 1.4.0.2 → 1.4.1.0
raw patch · 5 files changed
+35/−9 lines, 5 filesdep ~basedep ~ghc-bignumPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, ghc-bignum
API changes (from Hackage documentation)
Files
- CHANGES.md +4/−0
- hashable.cabal +5/−4
- src/Data/Hashable/Class.hs +22/−3
- src/Data/Hashable/Generic/Instances.hs +2/−2
- src/Data/Hashable/Imports.hs +2/−0
CHANGES.md view
@@ -1,5 +1,9 @@ See also https://pvp.haskell.org/faq +## Version 1.4.1.0++ * Add instance for `Data.Array.Byte.ByteArray`.+ ## Version 1.4.0.2 * Restore older GHC support
hashable.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: hashable-version: 1.4.0.2+version: 1.4.1.0 synopsis: A class for types that can be converted to a hash value description: This package defines a class, 'Hashable', for types that@@ -39,7 +39,8 @@ || ==8.10.7 || ==9.0.1 || ==9.0.2- || ==9.2.1+ || ==9.2.4+ || ==9.4.1 extra-source-files: CHANGES.md@@ -84,7 +85,7 @@ include-dirs: include hs-source-dirs: src build-depends:- base >=4.5 && <4.17+ base >=4.5 && <4.18 , bytestring >=0.9 && <0.12 , containers >=0.4.2.1 && <0.7 , deepseq >=1.3 && <1.5@@ -96,7 +97,7 @@ -- Integer internals if impl(ghc >=9)- build-depends: ghc-bignum >=1.0 && <1.3+ build-depends: ghc-bignum >=1.0 && <1.4 if !impl(ghc >=9.0.2) build-depends: ghc-bignum-orphans >=0.1 && <0.2
src/Data/Hashable/Class.hs view
@@ -69,7 +69,7 @@ import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Unsafe as B import Data.Complex (Complex(..))-import Data.Int (Int8, Int16, Int32, Int64)+import Data.Int (Int8, Int16) import Data.List (foldl') import Data.Ratio (Ratio, denominator, numerator) import qualified Data.Text as T@@ -77,7 +77,7 @@ import qualified Data.Text.Internal as T import qualified Data.Text.Lazy as TL import Data.Version (Version(..))-import Data.Word (Word8, Word16, Word32, Word64)+import Data.Word (Word8, Word16) import Foreign.Marshal.Utils (with) import Foreign.Ptr (Ptr, FunPtr, IntPtr, WordPtr, castPtr, castFunPtrToPtr, ptrToIntPtr) import Foreign.Storable (alignment, peek, sizeOf)@@ -230,6 +230,10 @@ import Data.Tree.Functor.Classes () #endif +#if MIN_VERSION_base(4,17,0)+import qualified Data.Array.Byte as AB+#endif+ #include "MachDeps.h" infixl 0 `hashWithSalt`@@ -689,7 +693,7 @@ hash = hashStableName hashWithSalt = defaultHashWithSalt --- Auxillary type for Hashable [a] definition+-- Auxiliary type for Hashable [a] definition data SPInt = SP !Int !Int instance Hashable a => Hashable [a] where@@ -978,6 +982,21 @@ instance (Hashable1 f, Hashable1 g, Hashable a) => Hashable (FS.Sum f g a) where hashWithSalt = hashWithSalt1 #endif++#if MIN_VERSION_base(4,17,0)+-- | @since 1.4.1.0+instance Hashable AB.ByteArray where+ hashWithSalt salt (AB.ByteArray ba) =+ hashByteArrayWithSalt ba 0 numBytes salt+ `hashWithSalt` size+ where+ size = numBytes `quot` SIZEOF_HSWORD+ numBytes = I# (sizeofByteArray# ba)+#endif++-------------------------------------------------------------------------------+-- Hashed+------------------------------------------------------------------------------- -- | A hashable value along with the result of the 'hash' function. data Hashed a = Hashed a {-# UNPACK #-} !Int
src/Data/Hashable/Generic/Instances.hs view
@@ -63,12 +63,12 @@ -- [Note: Hashing a sum type] -- -- The tree structure is used in GHC.Generics to represent the sum (and--- product) part of the generic represention of the type, e.g.:+-- product) part of the generic representation of the type, e.g.: -- -- (C0 ... :+: C1 ...) :+: (C2 ... :+: (C3 ... :+: C4 ...)) -- -- The value constructed with C2 constructor is represented as (R1 (L1 ...)).--- Yet, if we think that this tree is a flat (heterogenous) list:+-- Yet, if we think that this tree is a flat (heterogeneous) list: -- -- [C0 ..., C1 ..., C2 ..., C3 ..., C4... ] --
src/Data/Hashable/Imports.hs view
@@ -1,11 +1,13 @@ -- | This module exists to avoid conditional imports -- and unused import warnings.+{-# LANGUAGE Safe #-} module Data.Hashable.Imports ( Int64, Int32, Word64, Word32, xor, shiftR, shiftL, ) where +import Prelude () import Data.Int (Int64, Int32) import Data.Word (Word64, Word32) import Data.Bits (xor, shiftR, shiftL)