[Haskell-cafe] apply function arguments in a list

Michael Mossey mpm at alumni.caltech.edu
Mon Oct 5 10:34:19 EDT 2009

If I have a list containing the arguments I want to give to a function, is 
there a general way to supply those arguments in a compact syntax?

In other words, I could have

args = [1,2,3]
f x y z = ...

I would write

t = f (args!!0) (args!!1) (args!!2)

but there may be a neater, more general syntax. I tried writing a fold with 
$, but I don't think that works because the type of each step is different. 

f :: a -> a -> a -> a
f x :: a -> a -> a
f x y :: a -> a
f x y z :: a

This would seem to preclude a general way of writing a function that 
supplies arguments from a list.

More information about the Haskell-Cafe mailing list