hashable 1.1.2.0 → 1.1.2.1
raw patch · 2 files changed
+22/−14 lines, 2 filesdep ~test-frameworkPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: test-framework
API changes (from Hackage documentation)
Files
- Data/Hashable.hs +20/−12
- hashable.cabal +2/−2
Data/Hashable.hs view
@@ -286,10 +286,11 @@ -- $blocks -- -- The functions below can be used when creating new instances of--- 'Hashable'. For example, the 'hashWithSalt' method for many string-like--- types can be defined in terms of either 'hashPtrWithSalt' or--- 'hashByteArrayWithSalt'. Here's how you could implement an instance for--- the 'B.ByteString' data type, from the @bytestring@ package:+-- 'Hashable'. For example, for many string-like types the+-- 'hashWithSalt' method can be defined in terms of either+-- 'hashPtrWithSalt' or 'hashByteArrayWithSalt'. Here's how you could+-- implement an instance for the 'B.ByteString' data type, from the+-- @bytestring@ package: -- -- > import qualified Data.ByteString as B -- > import qualified Data.ByteString.Internal as B@@ -302,18 +303,25 @@ -- > B.unsafeUseAsCStringLen bs $ \(p, len) -> -- > hashPtrWithSalt p (fromIntegral len) salt ----- The 'combine' function can be used to implement 'Hashable'--- instances for data types with more than one field, using this+-- Use 'hashWithSalt' to create a hash value from several values,+-- using this recipe:+--+-- > instance (Hashable a1, Hashable a2) => Hashable (a1, a2) where+-- > hash (a1, a2) = hash a1 `hashWithSalt` a2+--+-- You can combine multiple hash values using 'combine', using this -- recipe: ----- > instance (Hashable a, Hashable b) => Hashable (Foo a b) where--- > hashWithSalt s (Foo a b) = s `hashWithSalt` a `hashWithSalt` b+-- > combineTwo h1 h2 = 17 `combine` h1 `combine` h2 ----- A nonzero seed is used so the hash value will be affected by--- initial fields whose hash value is zero. If no seed was provided,--- the overall hash value would be unaffected by any such initial--- fields, which could increase collisions. The value 17 is+-- As zero is a left identity of 'combine', a nonzero "seed" is used+-- so that the number of combined hash values affects the final+-- result, even if the first hash values are zero. The value 17 is -- arbitrary.+--+-- When possible, use 'hashWithSalt' to compute a hash value from+-- multiple values instead of computing separate hashes for each value+-- and then combining them using 'combine'. -- | 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.1.2.0+Version: 1.1.2.1 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@@ -41,7 +41,7 @@ Main-is: Properties.hs Build-depends: base >= 4.0 && < 5, hashable,- test-framework >= 0.3.3 && < 0.4,+ test-framework >= 0.3.3 && < 0.5, test-framework-quickcheck2 >= 0.2.9 && < 0.3, QuickCheck >= 2.4.0.1, random == 1.0.*,