
* Herbert Valerio Riedel
Hi,
Michael Snoyman
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
?
I disagree that Monoid.First is not useful by itself. It solves the problem when you already have a list (or another data structure) of Maybes, and want to fold them. Expressing this through Option and Semigroup.First would require more code and run-time conversions. Roman