Commit 10ca8018 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Generalise constraint on `instance Monoid (Maybe a)` to Semigroup

This now becomes possible due to the introduction of the
Semigroup=>Monoid superclass relation (see #14191).

Reviewers: ekmett, RyanGlScott, austin, bgamari

Reviewed By: ekmett, RyanGlScott, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3972
parent 120c568a
......@@ -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',
-- 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
-- @since 2.01
instance Semigroup a => Monoid (Maybe a) where
mempty = Nothing
-- | For tuples, the 'Monoid' constraint on @a@ determines
......
......@@ -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)
......
......@@ -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’
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment