[Haskell-cafe] Newbie: Applying Unknown Number Arguments to A Partial Function

Chris Kuklewicz haskell at list.mightyreason.com
Fri May 19 04:10:50 EDT 2006


Aditya Siram wrote:
> I am trying to write a function 'applyArguments' which takes a function
> and a list and recursively uses element each in the list as an argument
> to the function. I want to do this for any function taking any number of
> arguments.
> 
> applyArgument f (arg) = f arg
> applyArgument f (arg:args) = applyArgument (f arg) args
> 
> This has failed in Hugs, so my question is: Can I conceptually do this?
> If so, what is the type signature of this function?
> 
> Deech
> 
> 

You can't do that, but there are other tricks that do work:

http://okmij.org/ftp/Haskell/types.html

which describes "Functions with the variable number of (variously typed)
arguments" and "Genuine keyword arguments"

-- 
Chris


More information about the Haskell-Cafe mailing list