From 90702ae3d05b980d4cc6aefc61adcf8e53172658 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Wed, 26 Nov 2025 21:04:39 +0100 Subject: [PATCH] Relax constraints on Semigroup and Monoid instances --- Data/HashMap/Internal.hs | 4 ++-- Data/HashSet/Internal.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Data/HashMap/Internal.hs b/Data/HashMap/Internal.hs index 8dc71452..a9ca4457 100644 --- a/Data/HashMap/Internal.hs +++ b/Data/HashMap/Internal.hs @@ -311,7 +311,7 @@ instance Bifoldable HashMap where -- -- >>> fromList [(1,'a'),(2,'b')] <> fromList [(2,'c'),(3,'d')] -- fromList [(1,'a'),(2,'b'),(3,'d')] -instance Hashable k => Semigroup (HashMap k v) where +instance Eq k => Semigroup (HashMap k v) where (<>) = union {-# INLINE (<>) #-} stimes = stimesIdempotentMonoid @@ -327,7 +327,7 @@ instance Hashable k => Semigroup (HashMap k v) where -- -- >>> mappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')]) -- fromList [(1,'a'),(2,'b'),(3,'d')] -instance Hashable k => Monoid (HashMap k v) where +instance Eq k => Monoid (HashMap k v) where mempty = empty {-# INLINE mempty #-} mappend = (<>) diff --git a/Data/HashSet/Internal.hs b/Data/HashSet/Internal.hs index aa0e2fbf..6f62b39d 100644 --- a/Data/HashSet/Internal.hs +++ b/Data/HashSet/Internal.hs @@ -187,7 +187,7 @@ instance Foldable.Foldable HashSet where -- -- >>> fromList [1,2] <> fromList [2,3] -- fromList [1,2,3] -instance Hashable a => Semigroup (HashSet a) where +instance Eq a => Semigroup (HashSet a) where (<>) = union {-# INLINE (<>) #-} stimes = stimesIdempotentMonoid @@ -206,7 +206,7 @@ instance Hashable a => Semigroup (HashSet a) where -- -- >>> mappend (fromList [1,2]) (fromList [2,3]) -- fromList [1,2,3] -instance Hashable a => Monoid (HashSet a) where +instance Eq a => Monoid (HashSet a) where mempty = empty {-# INLINE mempty #-} mappend = (<>)