All Topics  
Currying

 

   Email Print
   Bookmark   Link






 

Currying



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, currying, invented by Moses Schönfinkel
Moses Schönfinkel

Moses Ilyich Sch?nfinkel, also known as Moisei Isai'evich Sheinfinkel' ??????????? was a Russian logician and mathematician, known for the invention of combinatory logic....
 and Gottlob Frege
Gottlob Frege

Friedrich Ludwig Gottlob Frege was a Germany mathematics who became a logician and philosophy. He helped found both modern mathematical logic and analytic philosophy....
, and independently by Haskell Curry
Haskell Curry

Haskell Brooks Curry was an United States mathematician and logician. Curry is best known for his work in combinatory logic; while the initial concept of combinatory logic was based on a single paper by Moses Sch?nfinkel, much of the development was done by Curry....
, is the technique of transforming a function that takes multiple arguments
Parameter (computer science)

In computer programming, a parameter is a special kind of variable#In_computer_programming that refers to data that a subroutine receives to operate on....
 (or more accurately an n-tuple
Tuple

In mathematics, a tuple is a sequence of a specific number of values, called the components of the tuple. These components can be any kind of mathematical objects, where each component of a tuple is a value of a specified type....
 as argument) in such a way that it can be called as a chain of functions each with a single argument.

name "currying", coined by Christopher Strachey
Christopher Strachey

Christopher Strachey was a United Kingdom computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design....
 in 1967, is a reference to logician Haskell Curry. An alternative name, Schönfinkelisation, has been proposed.






Discussion
Ask a question about 'Currying'
Start a new discussion about 'Currying'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, currying, invented by Moses Schönfinkel
Moses Schönfinkel

Moses Ilyich Sch?nfinkel, also known as Moisei Isai'evich Sheinfinkel' ??????????? was a Russian logician and mathematician, known for the invention of combinatory logic....
 and Gottlob Frege
Gottlob Frege

Friedrich Ludwig Gottlob Frege was a Germany mathematics who became a logician and philosophy. He helped found both modern mathematical logic and analytic philosophy....
, and independently by Haskell Curry
Haskell Curry

Haskell Brooks Curry was an United States mathematician and logician. Curry is best known for his work in combinatory logic; while the initial concept of combinatory logic was based on a single paper by Moses Sch?nfinkel, much of the development was done by Curry....
, is the technique of transforming a function that takes multiple arguments
Parameter (computer science)

In computer programming, a parameter is a special kind of variable#In_computer_programming that refers to data that a subroutine receives to operate on....
 (or more accurately an n-tuple
Tuple

In mathematics, a tuple is a sequence of a specific number of values, called the components of the tuple. These components can be any kind of mathematical objects, where each component of a tuple is a value of a specified type....
 as argument) in such a way that it can be called as a chain of functions each with a single argument.

Nomenclature

The name "currying", coined by Christopher Strachey
Christopher Strachey

Christopher Strachey was a United Kingdom computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design....
 in 1967, is a reference to logician Haskell Curry. An alternative name, Schönfinkelisation, has been proposed.

Definition


Given a function f of type , then currying it makes a function . That is, takes an argument of type and returns a function of type . Uncurrying is the reverse transformation.

Intuitively, currying says "if you fix some argument
Parameter (computer science)

In computer programming, a parameter is a special kind of variable#In_computer_programming that refers to data that a subroutine receives to operate on....
s, you get a function of the remaining arguments". For example, if function div stands for the curried form of the division operation x / y, then div with the parameter x fixed at 1 is another function: the same as the function inv that returns the multiplicative inverse of its argument, defined by inv(y) = 1 / y.

The practical motivation for currying is that very often the functions obtained by supplying some but not all of the arguments to a curried function (often called partial application) are useful; for example, many languages have a function or operator similar to plus_one. Currying makes it easy to define these functions.

Some programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
s have built-in syntactic support for currying, where what looks like a multi-argument function is actually syntactic sugar for the function in curried form; notable examples are ML
ML programming language

ML is a general-purpose functional programming language developed by Robin Milner and others in the late 1970s at the University of Edinburgh, whose syntax is inspired by ISWIM....
 and Haskell
Haskell (programming language)

Haskell is a standardized, purely functional programming language with non-strict programming language, named after logician Haskell Curry. The goals of the language are described as:...
, where in both cases all functions have exactly one argument. This convention is also used in lambda calculus
Lambda calculus

In mathematical logic and computer science, lambda calculus, also written as ?-calculus, is a formal system designed to investigate function definition, function application and recursion....
, where functions also all have exactly one argument, and multi-argument functions are usually represented in curried form.

Any language that supports closure
Closure (computer science)

In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables....
s can be used to write curried functions.

Mathematical view


In theoretical computer science
Theoretical computer science

Theoretical computer science is the collection of topics of computer science that focuses on the more abstract, logical and mathematical aspects of computing, such as the theory of computation, analysis of algorithms, and semantics of programming languages....
, currying provides a way to study functions with multiple arguments in very simple theoretical models such as the lambda calculus
Lambda calculus

In mathematical logic and computer science, lambda calculus, also written as ?-calculus, is a formal system designed to investigate function definition, function application and recursion....
 in which functions only take a single argument.

When viewed in a set-theoretic light, currying becomes the theorem
Theorem

In mathematics, a theorem is a statement Mathematical proof on the basis of previously accepted or established statements such as axioms.In formal mathematical logic, the concept of a theorem may be taken to mean a formula that can be formal proof according to the deductive system of a fixed formal system....
 that the set of functions from to , and the set of functions from to the set of functions from to , are isomorphic.

In category theory
Category theory

In mathematics, category theory deals in an abstract way with mathematical structures and relationships between them: it abstracts from set s and function s to objects linked in diagrams by morphisms or arrows....
, currying can be found in the universal property
Universal property

In various branches of mathematics, a useful construction is often viewed as the ?most efficient solution? to a certain problem. The definition of a universal property uses the language of category theory to make this notion precise....
 of an exponential object
Exponential object

In mathematics, specifically in category theory, an exponential object is the categorical equivalent of a function space in set theory. Categories with all product and exponential objects are called cartesian closed category....
, which gives rise to the following adjunction in cartesian closed categories
Cartesian closed category

In category theory, a category is cartesian closed if, roughly speaking, any morphism defined on a product of two objects can be naturally identified with a morphism defined on one of the factors....
: There is a natural
Natural transformation

In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure of the categories involved....
 isomorphism
Isomorphism

In abstract algebra, an isomorphism is a bijection map f such that both f and its inverse function f −1 are homomorphisms, i.e., structure-preserving mappings....
 between the morphisms from a binary product
Product (category theory)

In category theory, the product of two objects in a category is a notion designed to capture the essence behind constructions in other areas of mathematics such as the cartesian product, the direct product of groups, the direct product of rings and the product topology....
  and the morphisms to an exponential object . In other words, currying is the statement that product
Product (category theory)

In category theory, the product of two objects in a category is a notion designed to capture the essence behind constructions in other areas of mathematics such as the cartesian product, the direct product of groups, the direct product of rings and the product topology....
 and Hom
Hom functor

In mathematics, specifically in category theory, Hom-sets, i.e. sets of morphisms between objects, give rise to important functors to the category of sets....
 are adjoint functors
Adjoint functors

In mathematics, adjoint functors are pairs of functors which stand in a particular relationship with one another, called an adjunction. The relationship of adjunction is ubiquitous in mathematics, as it rigorously reflects the intuitive notions of optimization and efficiency....
; this is the key property of being a Cartesian closed category
Cartesian closed category

In category theory, a category is cartesian closed if, roughly speaking, any morphism defined on a product of two objects can be naturally identified with a morphism defined on one of the factors....
.

Under the Curry-Howard correspondence, the existence of currying and uncurrying is equivalent to the logical theorem , as tuples (product type) corresponds to conjunction in logic, and function type corresponds to implication.

See also


  • Lazy evaluation
    Lazy evaluation

    In computer programming, lazy evaluation is the technique of delaying a computation until such time as the result of the computation is known to be needed....
  • Closure (computer science)
    Closure (computer science)

    In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables....
  • smn theorem


External links


  • (despite the name, the article actually describes partial function application, which is different from currying)
  • Currying in Algol68G
    ALGOL 68G

    ALGOL 68G or Algol 68 Genie is an ALGOL 68 Interpreter . ALGOL 68G is a nearly full implementation of ALGOL 68 as defined by the Revised Report and also implements partial parametrisation, which is an extension of ALGOL 68....
  • - post at Lambda-the-Ultimate.org