[Haskell-beginners] Folding an applicative functor, wait, .. what?

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Jan 8 13:53:00 CET 2011


On Sat, Jan 8, 2011 at 10:45 AM, Arlen Cuss <celtic at sairyx.org> wrote:
> I think there is probably an obvious solution I've missed... and hold on
> a minute!
>
> map (mconcat [show, anotherFunc, yetAnotherFunc]) [1..20]
>
> I just stumbled upon this. While I'm not 100% confident on what's just
> happened here, I thought I'd mail this out for everyone to enjoy the
> learning process that has been this email.

That's the Monoid b => Monoid (a->b) instance [1], but I don't think
it is anywhere near obvious =).

Cheers!

[1] http://hackage.haskell.org/packages/archive/base/4.3.0.0/doc/html/src/Data-Monoid.html#(line94)

-- 
Felipe.



More information about the Beginners mailing list