Chapter 8

Currying and Partial Application

WHAT’S IN THIS CHAPTER?

  • Decoupling Parameters
  • Manual and Automatic Currying
  • Applying Currying in Object Oriented Programming
  • Functional Modularization through Partial Application

At its core, functional programming is all about the application of functions and their use as building blocks of algorithms. Haskell Curry is the mathematician whose name is the origin of the term currying (as well as the functional language Haskell). He invented the concept of currying at roughly the same time as Moses Schönfinkel and Gottlob Frege. Currying makes it possible to view all functions as members of the class of functions that take only one parameter, regardless of the number of arguments needed to perform the actual calculation. It enables partial application, which is one of two techniques (the other being composition) that make functional modularization possible.

In some publications, the term currying is used to cover the technique of partial application as well as currying itself. Because C# is a language in which the curried form of a function is not the native approach, it makes sense to keep these two separate and define them distinctly.

Get Functional Programming in C#: Classic Programming Techniques for Modern Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.