liveBook · Manning

Currying

As explained in Learn Haskell by Example

curry is a Haskell function that converts a function taking a pair into a function taking two arguments.

Currying rewrites a function with multiple arguments as a sequence of unary functions. In Haskell, a function such as `f = \x -> \y -> ...` accepts one argument and returns another function. Because functions are values, partially applied functions can be collected, transformed, and combined into larger operations. section 8.4.1

Transforming CSV data

Optional CSV arguments become transformations. The slice interval is a tuple, so `mSliceOp = fmap (uncurry slice) mSliceInterval` adapts the binary `slice` function to accept that tuple. `uncurry` is the counterpart of `curry`: it converts a curried function into one receiving a pair, while `curry` performs the reverse conversion. section 8.4.1

How Learn Haskell by Example covers it

How deep it goes
Defines currying and its dual, then demonstrates tuple adaptation with `uncurry`; it stops short of deeper implementation details.
Examples
Demonstrates `f = \x -> \y -> ...`, `uncurry slice`, optional intervals, and composed CSV operations.
What it assumes
Builds on treating functions as values and understanding unary functions, while introducing their use in composable transformations.
What you can do after
Apply currying and uncurrying in Haskell to adapt function shapes and compose argument-driven transformations.
How it connects
Connects currying with unary functions, higher-order functions, tuples, partial application, function composition, and CSV transformations.

Also explained in

Compare how 7 books explain currying →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.