|
|
|
|
|
by eutectic
4105 days ago
|
|
This a common misconception. Partial application is like taking f(x, y) = x + y and turning it into f(y) = 1 + y by supplying x = 1. Currying is like taking the same function and turning it into (f(x))(y) = x + y. Expressing f as a higher-order single argument function in this way gives us the advantages of partial application using normal total application. A good example is the derivative function from calculus, which could be specified in at least two obvious ways. A simple, but ugly solution is to have it take a function and a point as arguments and return the value of the derivative at that point. Alternatively, it could take a function and return its derivative as a function, which could then be evaluated at many different points. This is the difference between e.g. (Float -> Float, Float) -> Float, and
(Float -> Float) -> (Float -> Float). Taking this idea to its logical conclusion and applying it to any multiple argument function gives you currying. |
|