packages feed

hashable 1.4.3.0 → 1.4.4.0

raw patch · 4 files changed

+102/−17 lines, 4 filesdep +os-stringdep ~basedep ~containersdep ~filepathPVP ok

version bump matches the API change (PVP)

Dependencies added: os-string

Dependency ranges changed: base, containers, filepath

API changes (from Hackage documentation)

Files

CHANGES.md view
@@ -1,5 +1,10 @@ See also https://pvp.haskell.org/faq +## Version 1.4.4.0++  * Depend on `os-string-2` for GHC-9.2++  * Support `filepath-1.5`+ ## Version 1.4.3.0   * Export `defaultHashWithSalt` and `defaultHash`.
hashable.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.12 name:               hashable-version:            1.4.3.0+version:            1.4.4.0 synopsis:           A class for types that can be converted to a hash value description:   This package defines a class, 'Hashable', for types that@@ -36,9 +36,10 @@    || ==8.10.7    || ==9.0.1    || ==9.0.2-   || ==9.2.5-   || ==9.4.4-   || ==9.6.1+   || ==9.2.8+   || ==9.4.8+   || ==9.6.4+   || ==9.8.2  extra-source-files:   CHANGES.md@@ -78,14 +79,26 @@   include-dirs:     include   hs-source-dirs:   src   build-depends:-      base        >=4.10.1.0 && <4.19-    , bytestring  >=0.10.8.2 && <0.12+      base        >=4.10.1.0 && <4.20+    , bytestring  >=0.10.8.2 && <0.13     , containers  >=0.5.10.2 && <0.7-    , deepseq     >=1.4.3.0  && <1.5-    , filepath    >=1.4.1.2  && <1.5+    , deepseq     >=1.4.3.0  && <1.6     , ghc-prim-    , text        >=1.2.3.0  && <1.3  || >=2.0 && <2.1+    , text        >=1.2.3.0  && <1.3  || >=2.0 && <2.2 +  if impl(ghc >=9.2)+    -- depend on os-string on newer GHCs only.+    -- os-string has tight lower bound on bytestring, which prevents+    -- using bundled version on older GHCs.+    build-depends: os-string >=2.0.2++    -- we also ensure that we can get filepath-1.5 only with GHC-9.2+    -- therefore there is else-branch with stricter upper bound.+    build-depends: filepath >=1.4.1.2 && <1.6++  else+    build-depends: filepath >=1.4.1.2 && <1.5+   if !impl(ghc >=9.2)     build-depends: base-orphans >=0.8.6 && <0.10 @@ -150,6 +163,7 @@   build-depends:       base     , bytestring+    , filepath     , ghc-prim     , hashable     , HUnit@@ -159,6 +173,9 @@     , test-framework-hunit     , test-framework-quickcheck2  >=0.2.9     , text                        >=0.11.0.5++  if impl(ghc >=9.2)+    build-depends: os-string    if !os(windows)     build-depends:    unix
src/Data/Hashable/Class.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE MagicHash             #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PackageImports        #-} {-# LANGUAGE PolyKinds             #-} {-# LANGUAGE ScopedTypeVariables   #-} {-# LANGUAGE Trustworthy           #-}@@ -87,7 +88,6 @@ import GHC.Base               (ByteArray#) import GHC.Conc               (ThreadId (..)) import GHC.Fingerprint.Type   (Fingerprint (..))-import GHC.Prim               (ThreadId#) import GHC.Word               (Word (..)) import System.IO.Unsafe       (unsafeDupablePerformIO) import System.Mem.StableName  (StableName, hashStableName)@@ -116,6 +116,10 @@  import GHC.Generics +#if MIN_VERSION_base(4,19,0)+import GHC.Conc.Sync (fromThreadId)+#else+import GHC.Prim (ThreadId#) #if __GLASGOW_HASKELL__ >= 904 import Foreign.C.Types (CULLong (..)) #elif __GLASGOW_HASKELL__ >= 900@@ -123,6 +127,7 @@ #else import Foreign.C.Types (CInt (..)) #endif+#endif  #ifdef VERSION_ghc_bignum import GHC.Exts        (Int (..), sizeofByteArray#)@@ -163,7 +168,25 @@ import GHC.Tuple (Solo (..)) #endif -#if MIN_VERSION_filepath(1,4,100)+-- filepath >=1.4.100 && <1.5 has System.OsString.Internal.Types module+#if MIN_VERSION_filepath(1,4,100) && !(MIN_VERSION_filepath(1,5,0))+#define HAS_OS_STRING_filepath 1+#else+#define HAS_OS_STRING_filepath 0+#endif++-- if we depend on os_string module, then it has System.OsString.Internal.Types+-- module as well+#ifdef MIN_VERSION_os_string+#define HAS_OS_STRING_os_string 1+#else+#define HAS_OS_STRING_os_string 0+#endif++#if HAS_OS_STRING_filepath && HAS_OS_STRING_os_string+import "os-string" System.OsString.Internal.Types (OsString (..), PosixString (..), WindowsString (..))+import qualified "filepath" System.OsString.Internal.Types as FP (OsString (..), PosixString (..), WindowsString (..))+#elif HAS_OS_STRING_filepath || HAS_OS_STRING_os_string import System.OsString.Internal.Types (OsString (..), PosixString (..), WindowsString (..)) #endif @@ -662,7 +685,7 @@     hashWithSalt salt sbs@(BSI.SBS ba) =         hashByteArrayWithSalt ba 0 (BSI.length sbs) (hashWithSalt salt (BSI.length sbs)) -#if MIN_VERSION_filepath(1,4,100)+#if HAS_OS_STRING_filepath || HAS_OS_STRING_os_string -- | @since 1.4.2.0 instance Hashable PosixString where     hashWithSalt salt (PosixString s) = hashWithSalt salt s@@ -676,6 +699,17 @@     hashWithSalt salt (OsString s) = hashWithSalt salt s #endif +#if HAS_OS_STRING_filepath && HAS_OS_STRING_os_string+instance Hashable FP.PosixString where+    hashWithSalt salt (FP.PosixString s) = hashWithSalt salt s++instance Hashable FP.WindowsString where+    hashWithSalt salt (FP.WindowsString s) = hashWithSalt salt s++instance Hashable FP.OsString where+    hashWithSalt salt (FP.OsString s) = hashWithSalt salt s+#endif+ #if MIN_VERSION_text(2,0,0)  instance Hashable T.Text where@@ -707,9 +741,9 @@  #endif --- | Compute the hash of a ThreadId.-hashThreadId :: ThreadId -> Int-hashThreadId (ThreadId t) = hash (fromIntegral (getThreadId t) :: Int)+#if !MIN_VERSION_base(4,19,0)+fromThreadId :: ThreadId -> Word64+fromThreadId (ThreadId t) = fromIntegral (getThreadId t)  -- this cannot be capi, as GHC panics. foreign import ccall unsafe "rts_getThreadId" getThreadId@@ -722,9 +756,10 @@ #else     :: ThreadId# -> CInt #endif+#endif  instance Hashable ThreadId where-    hash = hashThreadId+    hash = hash . fromThreadId     hashWithSalt = defaultHashWithSalt  instance Hashable (Ptr a) where
tests/Properties.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE BangPatterns, CPP, GeneralizedNewtypeDeriving, MagicHash,     Rank2Types, UnboxedTuples #-}-{-# LANGUAGE DeriveGeneric, ScopedTypeVariables #-}+{-# LANGUAGE DeriveGeneric, ScopedTypeVariables, PackageImports #-}  -- | QuickCheck tests for the 'Data.Hashable' module.  We test -- functions by comparing the C and Haskell implementations.@@ -30,6 +30,14 @@  import qualified Data.ByteString.Short as BS +#if MIN_VERSION_filepath(1,4,100) && !(MIN_VERSION_filepath(1,5,0))+import qualified "filepath" System.OsString.Internal.Types as FP+#endif++#ifdef MIN_VERSION_os_string+import qualified "os-string" System.OsString.Internal.Types as OS+#endif+ ------------------------------------------------------------------------ -- * Properties @@ -252,3 +260,23 @@  fromStrict :: B.ByteString -> BL.ByteString fromStrict = BL.fromStrict++------------------------------------------------------------------------+-- test that instances exist++instanceExists :: Hashable a => a -> ()+instanceExists _ = ()++#if MIN_VERSION_filepath(1,4,100) && !(MIN_VERSION_filepath(1,5,0))+_fp1, _fp2, _fp3 :: ()+_fp1 = instanceExists (undefined :: FP.OsString)+_fp2 = instanceExists (undefined :: FP.WindowsString)+_fp3 = instanceExists (undefined :: FP.PosixString)+#endif++#ifdef MIN_VERSION_os_string+_os1, _os2, _os3 :: ()+_os1 = instanceExists (undefined :: OS.OsString)+_os2 = instanceExists (undefined :: OS.WindowsString)+_os3 = instanceExists (undefined :: OS.PosixString)+#endif