nLab currying


Set theory

Type theory

natural deduction metalanguage, practical foundations

  1. type formation rule
  2. term introduction rule
  3. term elimination rule
  4. computation rule

type theory (dependent, intensional, observational type theory, homotopy type theory)

syntax object language

computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory

logicset theory (internal logic of)category theorytype theory
predicatefamily of setsdisplay morphismdependent type
proofelementgeneralized elementterm/program
cut rulecomposition of classifying morphisms / pullback of display mapssubstitution
introduction rule for implicationcounit for hom-tensor adjunctionlambda
elimination rule for implicationunit for hom-tensor adjunctionapplication
cut elimination for implicationone of the zigzag identities for hom-tensor adjunctionbeta reduction
identity elimination for implicationthe other zigzag identity for hom-tensor adjunctioneta conversion
truesingletonterminal object/(-2)-truncated objecth-level 0-type/unit type
falseempty setinitial objectempty type
proposition, truth valuesubsingletonsubterminal object/(-1)-truncated objecth-proposition, mere proposition
logical conjunctioncartesian productproductproduct type
disjunctiondisjoint union (support of)coproduct ((-1)-truncation of)sum type (bracket type of)
implicationfunction set (into subsingleton)internal hom (into subterminal object)function type (into h-proposition)
negationfunction set into empty setinternal hom into initial objectfunction type into empty type
universal quantificationindexed cartesian product (of family of subsingletons)dependent product (of family of subterminal objects)dependent product type (of family of h-propositions)
existential quantificationindexed disjoint union (support of)dependent sum ((-1)-truncation of)dependent sum type (bracket type of)
logical equivalencebijection setobject of isomorphismsequivalence type
support setsupport object/(-1)-truncationpropositional truncation/bracket type
n-image of morphism into terminal object/n-truncationn-truncation modality
equalitydiagonal function/diagonal subset/diagonal relationpath space objectidentity type/path type
completely presented setsetdiscrete object/0-truncated objecth-level 2-type/set/h-set
setset with equivalence relationinternal 0-groupoidBishop set/setoid with its pseudo-equivalence relation an actual equivalence relation
equivalence class/quotient setquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
-0-truncated higher colimitquotient inductive type
coinductionlimitcoinductive type
presettype without identity types
set of truth valuessubobject classifiertype of propositions
domain of discourseuniverseobject classifiertype universe
modalityclosure operator, (idempotent) monadmodal type theory, monad (in computer science)
linear logic(symmetric, closed) monoidal categorylinear type theory/quantum computation
proof netstring diagramquantum circuit
(absence of) contraction rule(absence of) diagonalno-cloning theorem
synthetic mathematicsdomain specific embedded programming language

homotopy levels


Category theory



Currying is a process of transforming an operation on two variables into an operation on one variable that returns a function taking the second variable as an argument. The term is used in computer science and the lambda calculus, where it is often technically important to have operations that act on only one variable at a time. But category theory also recognises it as a natural isomorphism in a closed monoidal category, namely the universal property of an exponential object; thus it is also known as taking the exponential transpose.

The inverse operation is, in the straightforward style of computer science, called uncurrying.

Currying is named after Haskell Curry, in accordance with Stigler's law of eponymy, since it was invented by Moses Schönfinkel. (Perhaps Curry helped popularize the application to lambda calculus?)


In set theory

In set theory, currying transforms a function defined on a product set to a function that takes values in a function set. That is, starting with

f:X×YZ, f\colon X \times Y \to Z ,

we curry ff to produce

f^:XZ Y \hat{f}\colon X \to Z ^ Y

according to the formula

f^(x)=(yf(x,y)).\hat{f}(x) = (y \mapsto f(x, y)).

This is simply applying the universal property of the function set Z YZ^Y.

 In dependent type theory

In dependent type theory, currying transforms a family of elements defined on a dependent pair type to a family of elements that takes values in a dependent function type. That is, starting with

z: x:XY(x)f(z):Z(z)z:\sum_{x:X} Y(x) \vdash f(z):Z(z)

we curry ff to produce

x:Xf^(x): y:Y(x)Z(x,y)x:X \vdash \hat{f}(x):\prod_{y:Y(x)} Z(x, y)

according to the formula

f^(x)(λy.f(x,y)).\hat{f}(x) \coloneqq (\lambda y.f(x, y)).

This is simply applying the universal property of the dependent function type y:Y(x)Z(x,y)\prod_{y:Y(x)} Z(x, y).

In lambda calculus and CCCs

Similarly, in lambda calculus, currying is a device which reduces the study of functions in several arguments to functions in one argument. For example, if ϕ\phi is a lambda term in which variables xx and yy occur freely (so that ϕ\phi is effectively a “function” of xx and yy), the lambda calculus syntax favors the currified expression λx.λy.ϕ\lambda x. \lambda y. \phi, which denotes the intuitive expression x(yϕ)x \mapsto (y \mapsto \phi), where one abstracts variables one at a time.

Later it was observed (by Lawvere) that this is just a special case of a more general “curryfication” for cartesian closed categories (such as Cat or a nice category of spaces), where one has a natural bijection of morphisms:

X×YZXZ Y\frac{X \times Y \to Z}{X \to Z^Y}

Indeed, cartesian closed categories are models for lambda calculus.

In general

In fact, currying can be done in any (right) closed monoidal category. In that case, currying transforms a morphism whose source is a tensor product to a morphism whose target is an internal hom. That is, starting with

f:XYZ, f\colon X \otimes Y \to Z ,

we curry ff to produce

f^:X[Y,Z]. \hat{f}\colon X \to [Y, Z] .

Currying is invertible and natural in X,Y,ZX, Y, Z; that is, ff^f \mapsto \hat{f} is a natural isomorphism (in any closed monoidal category).

Currying in which variable(s)?

By convention, currying is always done on the last variable. This fits in very nicely with a convention that products associate on the left while internal homs associate on the right. More explicitly, if we use (as is common in computer science) ‘×\times’ for the product (even if it is not cartesian) and ‘toto’ for the internal hom (so that we must use another symbol, say ‘\vdash’, for the external hom), then we need no parentheses to generalise currying

f:X×YZ f\colon X \times Y \vdash Z

to produce

f^:XYZ; \hat{f}\colon X \vdash Y \to Z ;

by currying several n1n-1 times in succession, we turn

f:X 1××X nZ f\colon X_1 \times \cdots \times X_n \vdash Z


f^^:X 1X 2X nZ. \hat{\overset\vdots{\hat{f}}}\colon X_1 \vdash X_2 \to \cdots \to X_n \to Z .

This does not generalise to n=0n = 0, which is one way to see that even the untyped lambda calculus actually has two objects, one of which is a terminal object 11 and one of which can play every other role.

In a closed braided monoidal category (such as a closed symmetric monoidal category, and including the cartesian closed categories such as SetSet and the models of lambda calculus), we can also ‘curry through the first variable’ or ‘co-curry’ to produce a map

fˇ:YXZ, \check{f}\colon Y \vdash X \to Z ,

but computer scientists (or even mathematicians who are being very careful) will see this as a composite operation whose first step is composition with the braiding Y×XX×YY \times X \vdash X \times Y.

In a left closed monoidal category, currying does not exist, but cocurrying does. Perhaps the product should associate on the right in a left closed monoidal category?

 See also


For currying in dependent type theory, see

Last revised on January 7, 2023 at 01:28:24. See the history of this page for a list of all contributions to it.