Currying turns a function that needs several arguments into a sequence of functions that each accept one argument. Instead of running immediately with missing values, a curried function keeps returning a function until it has everything needed to produce a result. This makes it possible to supply configuration now and the changing value later. section 4.3
Figure 4.6. Evaluating a curried function f. The function produces a concrete result only when all arguments have been provided; otherwise, it returns another function that waits for these parameters to be passed in.
A curried call yields another waiting function until every required argument has been supplied; only then does it yield a concrete value. section 4.3
This is useful when a multi-argument function prevents easy composition. By fixing some arguments first, currying reduces the remaining function to a unary function, which can fit into a pipeline. It also creates small reusable function templates instead of repeating the same setup at every call site. section 1.2 section 4.3
Build a two-argument currier
A regular function receives both values at once: `fullname(first, last)`. A curried version receives `first`, returns a function, and that returned function receives `last`: `function curry2(fn) { return function(firstArg) { return function(secondArg) { return fn(firstArg, secondArg); }; }; }` Calling `name('Curry')('Haskell')` supplies the values in steps. Calling only `name('Curry')` produces a function that has remembered the first value through a closure. section 4.3
The remembered first argument is what makes currying practical. A type checker can first capture the expected type—`checkType(String)`—and then be reused against many values. Likewise, a student lookup can capture a database or array first and leave an SSN as the final input, so the caller uses one consistent `findStudent(ssn)` function regardless of storage choice. section 4.3 section 4.3
Currying helps when you want to:
- Preconfigure stable dependencies such as a database, logger appender, layout, or logger name. section 4.3
- Turn a function with several parameters into a unary function that can participate in `run` or another pipeline. section 1.2
- Separate data lookup and DOM updates into smaller pieces, isolating impure work from the main flow. section 1.2
Currying adds flexibility, but it is not free. Each staged call is a nested function execution and uses additional function-context stack frames. In a heavily repeated calculation, the extra overhead can be substantial enough to halt a browser, so use currying for modularity and reuse rather than indiscriminately in performance-sensitive inner loops. section 7.1 section 7.1
In JavaScript, currying must be supplied explicitly, either with a small helper such as `curry2` or with `R.curry`. The payoff is a function that can be configured in stages, reused in several places, and composed more easily with other single-input functions. section 4.3 section 4.2






