hashable 1.2.1.0 → 1.2.2.0
raw patch · 5 files changed
+212/−48 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES +0/−46
- CHANGES.md +174/−0
- Data/Hashable/Class.hs +18/−0
- hashable.cabal +2/−2
- tests/Properties.hs +18/−0
− CHANGES
@@ -1,46 +0,0 @@-Version 1.1.1.0--* Improved instances for tuples and lists.--* Added instances for StableName, Float, Double, Integer, and Ratio.--Version 1.1.1.0--* Added hashWithSalt, which allows the user to create different hash- values for the same input by providing different seeds. This is- useful for application like Cuckoo hashing which need a family of- hash functions.--* Fixed a bug in the Hashable instance for Int64/Word64 on 32-bit- platforms.--* Improved resilience to leading zero in the input being hashed.--Version 1.1.0.0--* Added instance for: strict and lazy Texts, ThreadId--* Added hashPtrWithSalt and hashByteArrayWithSalt.--* Faster ByteArray# hashing.--* Fixed a signedness bug that affected ByteString.--* Fix ByteString hashing to work correctly on both 32 and 64-bit- platforms.--Version 1.0.1.1--* Fixed bug in Hashable instance for lazy ByteStrings where- differences in the internal structure of the ByteString could cause- different hash values for ByteStrings that are equal according to- ==.--Version 1.0.1.0--* Added two helpers for creating Hashable instances: hashPtr and- hashByteArray.--Version 1.0.0--* Separated Hashable class to its own package from hashmap 1.0.0.3.
+ CHANGES.md view
@@ -0,0 +1,174 @@+## Version 1.2.2.0++ * Add instances for `Data.ByteString.Short`++ * Use a 32-bit default salt on 32-bit archs.++## Version 1.2.1.0++ * Revert instances to their 1.1 implementations to regain the+ performance we had then.++ * Remove use of random salt altogether. Without using SipHash the+ benefit is unclear (i.e. collision attacks still work) and the+ complexity is no longer worth it.++ * Documentation improvements.++## Version 1.2.0.10++ * Fix for GHC 7.0.++## Version 1.2.0.9++ * Stop using SipHash. The current implementation still has segfault+ causing bugs that we won't be able to fix soon.++ * Stop using Wang hash. It degrades performance of fixed-size integer+ hashing too much.++## Version 1.2.0.8++ * Fix linking issue when SSE was disabled.++ * Hash small signed Integers correctly.++## Version 1.2.0.7++ * Add flags to control usage of SSE.++## Version 1.2.0.6++ * Fix another segfault caused by SSE2 code.++## Version 1.2.0.5++ * More portability fixes.++ * Force stack alignment to 16 bytes everywhere. Fixes a segfault.++ * Fix bug where code relied on rewrite rules firing for correctness.++## Version1.2.0.4++ * Update docs to match code.++ * Work around bug in GHCi runtime linker, which never call static+ initializers.++## Version1.2.0.3++ * Make building of SSE 4.1 code conditional, as it doesn't work on all+ platforms.++ * Use a fixed salt, but allow random salting. Random salting by+ default broke people's code.++## Version1.2.0.2++ * Work around ghci linker bug on Windows.++## Version1.2.0.1++ * Fix performance bug in SSE implementation of SipHash.++ * Fix segfault due to incorrect stack alignment on Windows.++## Version1.2.0.0++ * Switch string hashing from FNV-1 to SipHash, in an effort to+ prevent collision attacks.++ * Switch fixed-size integer hashing to Wang hash.++ * The default salt now switched on every program run, in an effort to+ prevent collision attacks.++ * Move hash method out of Hashable type class.++ * Add support for generic instance deriving.++ * Add instance for Ordering.++## Version1.1.2.5++ * Bug fix for bytestring < 0.10.0.++## Version1.1.2.4++ * Switch string hashing from Bernstein to FNV-1++ * Faster instance for Integer.++ * Update dependency on base, ghc-prim++ * Now works with GHC 7.6.++## Version1.1.2.3++ * Add instance for TypeRep.++ * Update dependency on test-framework.++## Version1.1.2.2++ * Bug fix for GHC 7.4++## Version1.1.2.1++ * Update dependency on test-framework.++ * Improve documentation of combine.++## Version1.1.2.0++ * Add instances for Interger, Ratio, Float, Double, and StableName.++ * Fix hash collision issues for lists and tuples when using a+ user-specified salt.++## Version1.1.1.0++ * Improved instances for tuples and lists.++ * Add instances for StableName, Float, Double, Integer, and Ratio.++## Version1.1.1.0++ * Add hashWithSalt, which allows the user to create different hash+ values for the same input by providing different seeds. This is+ useful for application like Cuckoo hashing which need a family of+ hash functions.++ * Fix a bug in the Hashable instance for Int64/Word64 on 32-bit+ platforms.++ * Improved resilience to leading zero in the input being hashed.++## Version1.1.0.0++ * Add instance for: strict and lazy Texts, ThreadId++ * Add hashPtrWithSalt and hashByteArrayWithSalt.++ * Faster ByteArray# hashing.++ * Fix a signedness bug that affected ByteString.++ * Fix ByteString hashing to work correctly on both 32 and 64-bit+ platforms.++## Version1.0.1.1++ * Fix bug in Hashable instance for lazy ByteStrings where differences+ in the internal structure of the ByteString could cause different+ hash values for ByteStrings that are equal according to ==.++## Version1.0.1.0++ * Add two helpers for creating Hashable instances: hashPtr and+ hashByteArray.++## Version1.0.0++ * Separate Hashable class to its own package from hashmap 1.0.0.3.
Data/Hashable/Class.hs view
@@ -83,6 +83,10 @@ import qualified Data.ByteString.Lazy.Internal as BL -- foldlChunks #endif +#if MIN_VERSION_bytestring(0,10,4)+import qualified Data.ByteString.Short.Internal as BSI+#endif+ #ifdef VERSION_integer_gmp import GHC.Exts (Int(..)) import GHC.Integer.GMP.Internals (Integer(..))@@ -97,7 +101,11 @@ -- | A default salt used in the implementation of 'hash'. defaultSalt :: Int+#if WORD_SIZE_IN_BITS == 64 defaultSalt = 0xdc36d1615b7400a4+#else+defaultSalt = 0x087fc72c+#endif {-# INLINE defaultSalt #-} -- | The class of types that can be converted to a hash value.@@ -364,6 +372,16 @@ instance Hashable BL.ByteString where hashWithSalt = BL.foldlChunks hashWithSalt++#if MIN_VERSION_bytestring(0,10,4)+instance Hashable BSI.ShortByteString where+#if MIN_VERSION_base(4,3,0)+ hashWithSalt salt sbs@(BSI.SBS ba) =+#else+ hashWithSalt salt sbs@(BSI.SBS ba _) =+#endif+ hashByteArrayWithSalt ba 0 (BSI.length sbs) salt+#endif instance Hashable T.Text where hashWithSalt salt (T.Text arr off len) =
hashable.cabal view
@@ -1,5 +1,5 @@ Name: hashable-Version: 1.2.1.0+Version: 1.2.2.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@@ -20,7 +20,7 @@ -- tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. Extra-source-files:- CHANGES, README.md, tests/Properties.hs, benchmarks/Benchmarks.hs+ CHANGES.md, README.md, tests/Properties.hs, benchmarks/Benchmarks.hs Flag integer-gmp Description: Are we using integer-gmp to provide fast Integer instances?
tests/Properties.hs view
@@ -29,6 +29,10 @@ import GHC.Generics #endif +#if MIN_VERSION_bytestring(0,10,4)+import qualified Data.ByteString.Short as BS+#endif+ ------------------------------------------------------------------------ -- * Properties @@ -46,6 +50,11 @@ ((BL.fromChunks . map (B.pack . nonEmpty)) `fmap` arbitrary) where nonEmpty (NonEmpty a) = a +#if MIN_VERSION_bytestring(0,10,4)+instance Arbitrary BS.ShortByteString where+ arbitrary = BS.pack `fmap` arbitrary+#endif+ -- | Validate the implementation by comparing the C and Haskell -- versions. pHash :: [Word8] -> Bool@@ -93,7 +102,13 @@ where (a,b) = T.splitAt (unCS c) t go _ [] = error "Properties.rechunk - The 'impossible' happened!" +#if MIN_VERSION_bytestring(0,10,4) -- | Content equality implies hash equality.+pBSShort :: BS.ShortByteString -> BS.ShortByteString -> Bool+pBSShort a b = if (a == b) then (hash a == hash b) else True+#endif++-- | Content equality implies hash equality. pBS :: B.ByteString -> B.ByteString -> Bool pBS a b = if (a == b) then (hash a == hash b) else True @@ -205,6 +220,9 @@ , testGroup "bytestring" [ testProperty "bytestring/strict" pBS , testProperty "bytestring/lazy" pBSLazy+#if MIN_VERSION_bytestring(0,10,4)+ , testProperty "bytestring/short" pBSShort+#endif , testProperty "bytestring/rechunk" pBSRechunk , testProperty "bytestring/rechunked" pBSLazyRechunked ]