[Haskell-cafe] Map Monoid instance (was commutative monoid?)

wren ng thornton wren at freegeek.org
Sat Jun 25 23:40:29 CEST 2011

On 6/25/11 2:15 PM, Erik Hesselink wrote:
> On Sat, Jun 25, 2011 at 19:07, Evan Laforge<qdunkan at gmail.com>  wrote:
>> On Sat, Jun 25, 2011 at 9:00 AM, Jens Blanck<jens.blanck at gmail.com> 
>>>>> 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.
> Brent Yorgey recently blogged about a fourth instance [1] which also
> uses the semigroup operation on the values, but treats Nothing as
> failure, returning Nothing.
> Erik
> [1] https://byorgey.wordpress.com/2011/04/18/monoids-for-maybe/

Ah, yes. I forgot about that one. Though technically that one actually
requires a monoid, not just a semigroup, since mempty = Just mempty.

Which furthers the point that most types have an abundance of monoid

Live well,

More information about the Haskell-Cafe mailing list