[Haskell-cafe] Alternative versus Monoid

Bas van Dijk v.dijk.bas at gmail.com
Wed Dec 21 14:10:01 CET 2011

On 16 December 2011 16:26, Yves Parès <limestrael at gmail.com> wrote:
> "1) What about the First type? Do we {-# DEPRECATE #-} it?"
> Personnaly, I'm in favor of following the same logic than Int:
> Int itself is not a monoid. You have to be specific: it's either Sum or
> Mult.
> It should be the same for Maybe: we remove its instance of Monoid, and we
> only use First and Last.

The reason you need to be specific with Int is that it's not clear
which semantics (sum or product) you want. The semantics of Maybe are
clear: it's failure-and-prioritized-choice.

Changing the order of the arguments of mappend should be the job of Dual.

If we really want to drop the Monoid instance for Maybe and keep First
and Last and also want to be consistent we should also drop the Monoid
instances of [a], a->b, Endo a and of all the tuples. And instead
define Monoid instance for First [a], Last [a], First (a->b), Last
(a->b), etc. I don't think this is what we want.



More information about the Libraries mailing list