From 56c5a7cf3f46f8c4186c7e606b0a69edb03ec6c7 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Thu, 27 Nov 2025 13:51:30 +0100 Subject: [PATCH 1/2] HashSet.difference: Relax Hashable constraint This fixes an oversight in #535. --- Data/HashSet/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/HashSet/Internal.hs b/Data/HashSet/Internal.hs index aa0e2fbf..ccaf971b 100644 --- a/Data/HashSet/Internal.hs +++ b/Data/HashSet/Internal.hs @@ -391,7 +391,7 @@ map f = fromList . List.map f . toList -- -- >>> HashSet.difference (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4]) -- fromList [1] -difference :: Hashable a => HashSet a -> HashSet a -> HashSet a +difference :: Eq a => HashSet a -> HashSet a -> HashSet a difference (HashSet a) (HashSet b) = HashSet (H.difference a b) {-# INLINABLE difference #-} From 2b0674eadff78a008f18ddf3e12e305497730e26 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Thu, 27 Nov 2025 13:55:17 +0100 Subject: [PATCH 2/2] Strict.differenceWith: Relax Hashable constraint Fixes an oversight in #542. --- Data/HashMap/Internal/Strict.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/HashMap/Internal/Strict.hs b/Data/HashMap/Internal/Strict.hs index fbfa94c0..9ca93603 100644 --- a/Data/HashMap/Internal/Strict.hs +++ b/Data/HashMap/Internal/Strict.hs @@ -620,7 +620,7 @@ traverseWithKey f = go -- encountered, the combining function is applied to the values of these keys. -- If it returns 'Nothing', the element is discarded (proper set difference). If -- it returns (@'Just' y@), the element is updated with a new value @y@. -differenceWith :: Hashable k => (v -> w -> Maybe v) -> HashMap k v -> HashMap k w -> HashMap k v +differenceWith :: Eq k => (v -> w -> Maybe v) -> HashMap k v -> HashMap k w -> HashMap k v differenceWith f = HM.differenceWithKey $ \_k vA vB -> case f vA vB of Nothing -> Nothing