
On 06/11/13 14:46, John Wiegley wrote:
1. I propose that we add the following package to base:
http://hackage.haskell.org/packages/archive/semigroups/0.9.2/doc/html/Data-S...
This is somewhat in the spirit of the AMP proposal: further improving the correctness of our algebraic abstractions.
I was wondering how much longer until this proposal came up. +1 from me in general, but I have some quibbles with details.
2. That we make Semigroup a superclass of Monoid, so that (minimally):
class Semigroup a where (<>) :: a -> a -> a
class Semigroup a => Monoid a where mempty :: a mconcat :: [a] -> a mconcat = foldr (<>) mempty
mappend :: Semigroup a => a -> a -> a mappend = (<>)
+1, though I'd prefer to leave mappend restricted to the Monoid class. In the long term, I'd rather have it killed off than kept as a synonym for (<>). Besides, it's m(onoid)append.
3. (Optional, recommended) There are other useful functions that can be added to Semigroup, such as sconcat and times1p, but I will let Edward speak to whether those should be proposed at this time.
They should be added in now or never, there's no reason to break compatibility twice. I don't think times1p can be accepted in its current form as it depends on a different library. Edward, can you make a concrete proposal for these?
4. (Optional, recommended) That we fix the Monoid instance for Maybe to be:
instance Semigroup a => Monoid (Maybe a) where mempty = Nothing
instance Semigroup a => Semigroup (Maybe a) where Just x <> Just y = Just (x <> y) Nothing <> x = x x <> Nothing = x
+1