summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-02-11 15:33:27 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-20 13:57:34 -0500
commit845284a5ddceb043b1b1af6f130143f1ef160835 (patch)
treeaff71eacb5a36c9d71a907974030a59353c443bf
parent92ab3ff2fbed8847747b43592546f6b98a6d03ec (diff)
downloadhaskell-845284a5ddceb043b1b1af6f130143f1ef160835.tar.gz
Generically: remove redundant Semigroup constraint
This patch removes a redundant Semigroup constraint on the Monoid instance for Generically. This constraint can cause trouble when one wants to derive a Monoid instance via Generically through a type that doesn't itself have a Semigroup instance, for example: data Point2D a = Point2D !a !a newtype Vector2D a = Vector2D { tip :: Point2D a } deriving ( Semigroup, Monoid ) via Generically ( Point2D ( Sum a ) ) In this case, we should not require there to be an instance Semigroup ( Point2D ( Sum a ) ) as all we need is an instance for the generic representation of Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ).
-rw-r--r--libraries/base/GHC/Generics.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs
index d4f56fd1e6..6ce5b70083 100644
--- a/libraries/base/GHC/Generics.hs
+++ b/libraries/base/GHC/Generics.hs
@@ -1428,7 +1428,7 @@ instance (Generic a, Semigroup (Rep a ())) => Semigroup (Generically a) where
Generically a <> Generically b = Generically (to (from a <> from b :: Rep a ()))
-- | @since 4.17.0.0
-instance (Semigroup a, Generic a, Monoid (Rep a ())) => Monoid (Generically a) where
+instance (Generic a, Monoid (Rep a ())) => Monoid (Generically a) where
mempty :: Generically a
mempty = Generically (to (mempty :: Rep a ()))