Possible Duplicate:
Why is such a function definition not allowed in haskell?
Good day!
I'm trying to write/to find a function g that translate a list of arbitrary finite size to function arguments, such as
g k [a,b,c,d] = k a b c d
g f [a,b,c] = f a b c = ((((f) $ a) $ b) $ c)
Syntactically that seems like g = foldl ($) f
, but the compiler reasonably fails to apply that function, answering:
ghci> let (><) f = foldl ($) f
<interactive>:1:19:
Occurs check: cannot construct the infinite type: b = b1 -> b
Probable cause: `$' is applied to too many arguments
In the first argument of `foldl', namely `($)'
In the expression: foldl ($) f
So I fail to produce some working implementation. Do you have any ideas? Thank you in advance!