3
Is there any reason why this function:
foo f x y = f x y
foo x y = (+) x y
Return this error?
Equations for `foo' have Different Numbers of Arguments
Why doesn’t Haskell allow this behavior?
3
Is there any reason why this function:
foo f x y = f x y
foo x y = (+) x y
Return this error?
Equations for `foo' have Different Numbers of Arguments
Why doesn’t Haskell allow this behavior?
3
Note that in the first case you have 3 arguments (f, x, y), and in the second you have 2 arguments (only x and y).
If you wanted to specialize the application of f, then it is better to create another function. Ex:
foosum x y = foo (+) x y
Browser other questions tagged haskell
You are not signed in. Login or sign up in order to post.
Or simply
foosum = foo (+)
(since the functions suffer curry by default).– mgibsonbr
I know they have different amounts of parameters. What I want to know is why it doesn’t work, the design decision that shaped this aspect of language.
– ptkato
the reason is to be able to use partially applied functions
– neu-rah