From 9d1c9bcf99e4b5dc4f3c0ede46bcda84203bfeac Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Apr 2017 12:27:58 -0400 Subject: improve --- Hash.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Hash.hs') diff --git a/Hash.hs b/Hash.hs index 9b5fa80..ed4513b 100644 --- a/Hash.hs +++ b/Hash.hs @@ -35,10 +35,8 @@ instance Hashable a => Hashable (Tagged a) where hash (Tagged b a) = hash [hash b, hash a] instance Hashable a => Hashable (Activity a) where - hash (Activity a (Just p) s) = hash $ Tagged "Activity" - [hash a, hash p, hash s] - hash (Activity a Nothing s) = hash $ Tagged "Activity" - [hash a, hash (), hash s] + hash (Activity a mp s) = hash $ Tagged "Activity" + [hash a, hash mp, hash s] instance Hashable a => Hashable (Proto a) where hash (Proto a) = hash $ Tagged "Proto" a @@ -58,6 +56,7 @@ instance Hashable Signature where instance Hashable [Hash] where hash = hash . B.concat . map (val . hashValue) --- | Hash empty string for () -instance Hashable () where - hash () = hash (mempty :: B.ByteString) +-- | Hash empty string for Nothing +instance Hashable v => Hashable (Maybe v) where + hash Nothing = hash (mempty :: B.ByteString) + hash (Just v) = hash v -- cgit v1.2.3