[Haskell-cafe] polyvariadic function for Applicative instances

Bartek Ćwikłowski paczesiowa at gmail.com
Sun May 9 16:58:20 EDT 2010


hello,

> Is it possible to have a function accept variable number of
> arguments, such that 'f' can be instantiated to different
> concrete types as
>
> f :: Applicative a => (e1 -> f) -> a e1 -> A f
> f g a = pure g <*> a
>
> f :: Applicative a => (e1 -> e2 -> f) -> a e1 -> a e2 -> A f
> f g a b = pure g <*> a <*> b

f is just a left fold over the list of arguments. I've written about
such things here:
http://paczesiowa.blogspot.com/2010/03/generalized-zipwithn.html

regards,
Bartek Ćwikłowski


More information about the Haskell-Cafe mailing list