Maximum and Minimum monoids

Herbert Valerio Riedel hvr at gnu.org
Fri Dec 28 10:42:06 CET 2012


Hi,

Michael Snoyman <michael at snoyman.com> writes:
[...]
>> Because they're properly represented as semigroups too, just like Min and
>> Max (i.e. they don't behave sensibly "out of the box" on empty lists). The
>> semigroups package already provides the proper types and instances. And
>> just like Min and Max, the semigroups package lets you "lift" its First and
>> Last into Monoids with the Option type.

> Just because such a lifting is possible doesn't mean that it will be
> intuitive or obvious to new users. (I wouldn't know how to make this
> switch, for example.)

...this seems to call for better documentation (including
examples) of the Data.Semigroup.Option Monoid instance then.

Do you have an example where it might not be obvious how to use 

  Option (Semigroup.First a)

instead of

  Monoid.First a

?

cheers,
  hvr



More information about the Libraries mailing list