Maximum and Minimum monoids

Michael Snoyman michael at snoyman.com
Fri Dec 28 07:37:51 CET 2012


On Fri, Dec 28, 2012 at 8:30 AM, Gershom Bazerman <gershomb at gmail.com>wrote:

> On 12/28/12 1:20 AM, Michael Snoyman wrote:
>
>>
>>
>> +1 for moving semigroups into the platform, but what's the motivation for
>> removing First and Last from Data.Monoid?
>>
>>
> 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.) First and Last as currently provided by the
Data.Monoid module provide some very useful functionality; I've used them
in the past for such things as representing nested config files. I wouldn't
want to provide a default value for the options, but want to use the first
(or last) value in the file.

So count me as -1 to modifications to First and Last.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20121228/502471bb/attachment.htm>


More information about the Libraries mailing list