Skip to content

Commit e7a2ead

Browse files
committed
HashMap: Add Hashable instance
1 parent 56e3eed commit e7a2ead

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Data/HashMap/Base.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ instance Traversable (HashMap k) where
203203
instance (Eq k, Eq v) => Eq (HashMap k v) where
204204
(==) = equal
205205

206+
instance (Hashable k, Hashable v) => Hashable (HashMap k v) where
207+
hashWithSalt = foldlWithKey' (\h k v -> h `H.hashWithSalt` k `H.hashWithSalt` v)
208+
206209
equal :: (Eq k, Eq v) => HashMap k v -> HashMap k v -> Bool
207210
equal t1 t2 = go (toList' t1 []) (toList' t2 [])
208211
where

0 commit comments

Comments
 (0)