Search code examples
haskellcurryingpartial-application

Are the concepts of partial application and currying interchangeable in Haskell?


In some functional languages, partially applied functions and curried functions are two similar but distinct concepts.

Reading the book Learn You a Haskell for Great Good, the author appears to apply these interchangeably.

[Curried functions] Every function in Haskell officially only takes one parameter.

...

if we call a function with too few parameters, we get back a partially applied function, meaning a function that takes as many parameters as we left out.

My question is: Are the concepts of partial application and currying interchangeable in Haskell?


Solution

  • They are different but related concepts. Because function definitions are curried, when you partially apply a function (ie, call it with fewer arguments than it expects), you get back another function that expects fewer arguments.

    The process of currying is replacing an N-ary function with N "layers" of unary functions so that you can partially apply it, turning

    function(x,y) {return x+y;}
    

    into

    function(x) {return function(y) {return x+y;};}
    

    The currying is part of defining the function, and partial application is what you do with a function when you call it.