diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs index 82b99a88c2742c963b5276a51ed488306de84164..052f13fbe6f66b35ef88229bd41b2dcf5ede9f15 100644 --- a/libraries/base/GHC/Base.hs +++ b/libraries/base/GHC/Base.hs @@ -413,12 +413,13 @@ instance Semigroup a => Semigroup (Maybe a) where -- | Lift a semigroup into 'Maybe' forming a 'Monoid' according to -- <http://en.wikipedia.org/wiki/Monoid>: \"Any semigroup @S@ may be -- turned into a monoid simply by adjoining an element @e@ not in @S@ --- and defining @e*e = e@ and @e*s = s = s*e@ for all @s ∈ S@.\" Since --- there used to be no \"Semigroup\" typeclass providing just 'mappend', --- we use 'Monoid' instead. +-- and defining @e*e = e@ and @e*s = s = s*e@ for all @s ∈ S@.\" +-- +-- /Since 4.11.0/: constraint on inner @a@ value generalised from +-- 'Monoid' to 'Semigroup'. -- -- @since 2.01 -instance Monoid a => Monoid (Maybe a) where +instance Semigroup a => Monoid (Maybe a) where mempty = Nothing -- | For tuples, the 'Monoid' constraint on @a@ determines diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index eac53ba079ec948654443635c96cbe37a2be0647..f64129965f73b9761a15c4039b543f67042a65b6 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -14,6 +14,9 @@ export `Semigroup` from `Prelude`; remove `Monoid` reexport from `Data.Semigroup` (#14191). + * Generalise `instance Monoid a => Monoid (Maybe a)` to + `instance Semigroup a => Monoid (Maybe a)`. + * Add `infixl 9 !!` declaration for `Data.List.NonEmpty.!!` * Add `<&>` operator to `Data.Functor` (#14029) diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout index 7b630f1ed9b97e427f49382f41d2b2232353015e..c7421b58afc9b1501ce1bb53d41fd124bfbad791 100644 --- a/testsuite/tests/ghci/scripts/T4175.stdout +++ b/testsuite/tests/ghci/scripts/T4175.stdout @@ -34,7 +34,7 @@ instance Applicative Maybe -- Defined in ‘GHC.Base’ instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’ instance Functor Maybe -- Defined in ‘GHC.Base’ instance Monad Maybe -- Defined in ‘GHC.Base’ -instance Monoid a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ +instance Semigroup a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Base’ instance Semigroup a => Semigroup (Maybe a) -- Defined in ‘GHC.Base’