Skip to content

Commit 56e3eed

Browse files
committed
HashSet: Add Hashable instance
Given that [a] has a Hashable instance and we already depend upon hashable, it seems reasonable that HashSet should have one as well.
1 parent 0d7fd39 commit 56e3eed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Data/HashSet.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module Data.HashSet
6565
import Control.DeepSeq (NFData(..))
6666
import Data.Data hiding (Typeable)
6767
import Data.HashMap.Base (HashMap, foldrWithKey)
68-
import Data.Hashable (Hashable)
68+
import Data.Hashable (Hashable(hashWithSalt))
6969
#if __GLASGOW_HASKELL__ < 709
7070
import Data.Monoid (Monoid(..))
7171
#endif
@@ -127,6 +127,9 @@ instance (Data a, Eq a, Hashable a) => Data (HashSet a) where
127127
dataTypeOf _ = hashSetDataType
128128
dataCast1 f = gcast1 f
129129

130+
instance (Hashable a) => Hashable (HashSet a) where
131+
hashWithSalt = foldl' hashWithSalt
132+
130133
fromListConstr :: Constr
131134
fromListConstr = mkConstr hashSetDataType "fromList" [] Prefix
132135

0 commit comments

Comments
 (0)