Skip to content

Partial Application vs Currying

Daisho edited this page Aug 10, 2019 · 3 revisions

Here's tl;dr of Partial Application and Currying characteristics.

  1. Both are specialization techniques
  2. Partial Application presets some arguments now, receives the rest on the next call
  3. Currying doesn't preset any arguments, receives each argument one at a time

If you ever get asked on a future job interview, what's the difference? What's partial application and currying? The answer is, both of them specialize, they do it differently.

  • Partial Application takes some input now, all the rest of the input later
  • Currying takes no input now, each input one at a time
1 const ajax = curry(3, function ajax(url, data, cb) {
2     //some work here
3 });
4
5 //strict currying
6 ajax(CUSTOMER_API)({id: 42})(renderCustmer);
7
8 //loose currying
9 ajax(CUSTOMER_API, {id: 42})(renderCustmer);

Currying has been like we see on line six, which is that each time I call the function I provide only one input. Because that's how we did it when we manually curried, that's how it works in Haskell, you provide one input at a time.

Clone this wiki locally