Currying transforms a two-argument function into a function that accepts one argument and returns another function. Its type, A => (B => C), means that supplying an A produces a function from B to C; the first argument is therefore partially applied. section 2.5
A curried function in Scala
def curry[A, B, C](f: (A, B) => C): A => (B => C) = a => b => f(a, b) The outer function receives a, and the returned function receives b. Together they apply both arguments to f. section 2.7 section 2.5
Currying belongs to a small group of related function transformations:
- partial1 fixes one argument of a two-argument function and returns a one-argument function. section 2.5
- uncurry reverses curry, converting A => B => C into (A, B) => C. section 2.5
- compose combines functions by feeding one function’s output into another’s input. section 2.5
def curry[A, B, C](f: (A, B) => C): A => (B => C) = a => b => f(a, b)
Inspect the complete polymorphic Scala definition of curry. section 2.7
