[Haskell-cafe] commutative monoid?

Brent Yorgey byorgey at seas.upenn.edu
Sat Jun 25 23:02:45 CEST 2011


On Fri, Jun 24, 2011 at 11:13:46PM -0700, wren ng thornton wrote:
> On 6/25/11 1:34 AM, Evan Laforge wrote:
> > So there's a range of possible Monoid instances for each type,
> 
> More for some types than for others. For Maybe there are three:
> 
>  * always take the first/left value;
>  * always take the last/right value;
>  * or, use a semigroup operation defined on the values.

Actually, there are (at least) four: there's also the one where
mappend = liftA2 mappend, i.e. introduce potential failure into a
monoid operation defined on the values.  I wrote about it here:

    http://byorgey.wordpress.com/2011/04/18/monoids-for-maybe/

-Brent



More information about the Haskell-Cafe mailing list