are functions that take multiple arguments one at a time instead of as tuples.

Using the fact that functions can return other functions we can define curried functions in two ways:

  • a function of multiple arguments that returns a non-function output.
  • a function of a single (the leftmost) argument that returns a functions that takes the remaining arguments as arguments. The returned function can itself be defined in these two ways.

Examples

A function that adds two numbers a and b can be defined as

  • a function that takes both a and b as arguments
    add :: (Int -> Int) -> Int
    add a b = a + b
  • a function that takes a as single argument and returns a function that takes b as argument, has a body where a is defined, and returns an int
    add :: Int -> (Int -> Int)
    add a b = a + b