Proposal: Add Data.Semigroup to base, as a superclass of Monoid

John Wiegley johnw at fpcomplete.com
Tue Jun 11 20:51:50 CEST 2013


>>>>> John Wiegley <johnw at fpcomplete.com> writes:

> 4. (Optional, recommended) That we fix the Monoid instance for Maybe to be:

>     instance Semigroup a => Semigroup (Maybe a) where
>          Just x <> Just y = Just (x <> y)
>          _ <> _ = Nothing

Slight correction (thanks to Brent Yorgey for catching this):

    instance Semigroup a => Semigroup (Maybe a) where
         Just x <> Just y = Just (x <> y)
         Nothing <> x = x
         x <> Nothing = x

-- 
John Wiegley
FP Complete                         Haskell tools, training and consulting
http://fpcomplete.com               johnw on #haskell/irc.freenode.net



More information about the Libraries mailing list