Maximum and Minimum monoids
michael at snoyman.com
Fri Dec 28 10:58:39 CET 2012
On Fri, Dec 28, 2012 at 11:42 AM, Herbert Valerio Riedel <hvr at gnu.org>wrote:
> Michael Snoyman <michael at snoyman.com> writes:
> >> Because they're properly represented as semigroups too, just like Min
> >> Max (i.e. they don't behave sensibly "out of the box" on empty lists).
> >> semigroups package already provides the proper types and instances. And
> >> just like Min and Max, the semigroups package lets you "lift" its First
> >> 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
I'm simply approaching this from the standpoint of a new user. Monoid is
enough of a hurdle to try and learn and understand properly. Now that the
user has learnt about Monoid, he/she goes to Data.Monoid because the Hoogle
documentation leads there, and currently finds the First and Last
datatypes. Case closed, objective achieved.
If we remove First and Last, then the user now needs to:
1. Realize that semigroups exist
2. Realize that they are related to Monoid
3. Find the documentation for them
4. Understand that Option can be composed with First to create a Monoid
Perhaps adding a bunch of documentation to Data.Monoid could solve this,
but I simply don't see that the current First and Last datatypes are
problematic enough that they should actually be removed.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries