Proposal: Make Semigroup as a superclass of Monoid

Reid Barton rwbarton at gmail.com
Mon May 4 14:19:30 UTC 2015


On Sun, Mar 29, 2015 at 8:20 AM, Jeremy <voldermort at hotmail.com> wrote:

> The proposal to make Semigroup a superclass of Monoid was discussed a while
> ago [1], and the conclusion was to "put this off until the dust has settled
> from the AMP and FT changes".
>
> Now that 7.10 is out, I would like to re-propose. The proposed plan is
> similar to AMP, but less invasive, as (in my subjective experience)
> user-defined Monoids are much less common than user-defined Monads.
>
> 1. GHC 7.12 will include Semigroup and NonEmpty in base. All Monoid
> instances, and anything else which forms a Semigroup, will have a Semigroup
> instance. GHC will issue a warning when it encounters an instance of Monoid
> which is not an instance of Semigroup.
>

Strongly opposed to adding a NonEmpty type to base. It's a step in the
wrong direction:
the problem it clumsily tries to address is solved much better by
refinement types à la
LiquidHaskell, which handles this and other whole classes of problems at
once.

Now, we don't have LiquidHaskell in GHC yet; but let's not settle for
adding a NonEmpty
type that we know is an inferior approach to base now, when it will likely
be very hard
to remove it in the future.

I know there are some who use NonEmpty types currently, but I think their
needs are
just as well (if not better) met by putting the type in a small package
outside of base
with few dependencies.


>
> 2. GHC >7.12 will define Monoid as a subclass of Semigroup.
>

While it frustrates me to repeatedly see so much time spent by both GHC
developers
and Haskell library and application programmers on changes like this with
fairly small
upside, I don't have any fundamental objection to ending up in a state with
Semigroup
as a superclass of Monoid.

Regards,
Reid Barton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150504/42a391d3/attachment.html>


More information about the Libraries mailing list