Define a function with different quantities of arguments

3

There is some reason for 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 does not Haskell allow this behavior?

    
asked by anonymous 18.09.2015 / 03:55

1 answer

3

Notice 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
    
23.10.2015 / 14:09