[Haskell-cafe] Alternative versus Monoid

Matthew Farkas-Dyck strake888 at gmail.com
Wed Dec 21 21:42:54 CET 2011


On 21/12/2011, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> 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.
>
> Regards,
>
> Bas
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

Fair point. I concede.

If Monoid were necessarily inner-type-gnostic then we'd also have to
drop instance Monoid [a].

Cheers,
Matthew Farkas-Dyck



More information about the Haskell-Cafe mailing list