Re: [Haskell-cafe] commutative monoid?

2011-06-26 Thread Brent Yorgey
On Sat, Jun 25, 2011 at 02:34:47PM -0700, Evan Laforge wrote: On Sat, Jun 25, 2011 at 2:02 PM, Brent Yorgey byor...@seas.upenn.edu wrote: Actually, there are (at least) four: there's also the one where mappend = liftA2 mappend, i.e. introduce potential failure into a monoid operation

Re: [Haskell-cafe] commutative monoid?

2011-06-25 Thread wren ng thornton
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

Re: [Haskell-cafe] commutative monoid?

2011-06-25 Thread Evan Laforge
So is there a typeclass for that? There might be one hidden in one of the attempts at redesigning the numeric hierarchy (e.g., Numeric Prelude), but there's not a canonical typeclass for them. Unfortunately it's not really a good match for the typeclass system since it doesn't introduce any

Re: [Haskell-cafe] commutative monoid?

2011-06-25 Thread Henning Thielemann
On Fri, 24 Jun 2011, Evan Laforge wrote: So there's a range of possible Monoid instances for each type, and maybe they were chosen by historical happenstance rather than some kind of principle monoid (is there such a thing?). Is there a name for the thing that's like a monoid, but the

Re: [Haskell-cafe] commutative monoid?

2011-06-25 Thread Brent Yorgey
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

Re: [Haskell-cafe] commutative monoid?

2011-06-25 Thread Evan Laforge
On Sat, Jun 25, 2011 at 2:02 PM, Brent Yorgey byor...@seas.upenn.edu wrote: 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:    

[Haskell-cafe] commutative monoid?

2011-06-24 Thread Evan Laforge
Not being especially mathematically inclined, every once and a while I get a little panicked when I notice that, e.g. Data.Map mappend is a plain left-biased union, and doesn't actually mappend the values of the map. Then I remember that monoids are associative, not commutative, and it's totally