[plt-scheme] Why do layman programmers care about Currying?

From: Anthony Cowley (acowley at seas.upenn.edu)
Date: Wed Dec 31 01:26:41 EST 2008

On Tue, Dec 30, 2008 at 11:12 PM, Grant Rettke <grettke at acm.org> wrote:
> Why do layman (working programmers) care about Currying? Or how are
> they applied in daily use to help one out?
> http://en.wikipedia.org/wiki/Currying

There are many cases where Curried functions can be convenient, but
I'll just pick one class of examples. In FP, one is often passing
around bundles of state in the form of parameters to a function. If
that state is going to be updated on a regular basis, then one either
wants to give up purity, or seriously consider monads. However, there
are many cases where that state doesn't need to be updated, just
referred to. Suppose then that we made whatever pieces of state we
needed the first parameters to a pure function of multiple parameters.
If that function is Curried and given its first few parameters, then
the resulting partial application now has the necessary state tacked
into its scope in way that is transparent to subsequent callers of
that partial application. It is almost analogous to an implicit 'this'
parameter if you close one eye and squint and want to think of it in
an OO-way.

So you start with general functions, you give them some state, and now
they are instantiated in a sense. Callers of these new functions need
not worry about those static state parameters, while the author of the
function was able to consider, and test, his or her problem entirely


Posted on the users mailing list.