[plt-scheme] What is the big deal about the currying of functions?

From: Joe Marshall (jmarshall at alum.mit.edu)
Date: Thu May 24 18:31:14 EDT 2007

On 5/24/07, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> On May 24, 2007, at 6:02 PM, Grant Rettke wrote:
>
> > I hear folks talk about how great is a language when it lets you curry
> > functions, and that Scheme can do it too if you use macros.
> >
> > In your minds what is, and what is the value of, function currying?
>
> Auto-Currying (which is what you mean) is absolutely necessary in a
> lazy functional language

This isn't strictly (pun intended) true, is it?

With OCaml, you can have recursive types if you turn on a compiler
switch.  The problem with doing so is that if you accidently omit an
argument somewhere, the program will usually type check to a
horrendously complicated recursive function type.  Their solution is
to leave the switch off and not use recursive function types at all.

It seems to me that an alternate (and better) solution is to disallow
the automagic currying.

>
> Then again, when you program in a functional style and subset of
> something like Scheme, it would be nice to say things like
>
>  (map (+ 4) ...) meaning (map (lambda (x) (+ 4 x)) ...
>  (filter (< 4) ...) meaning (filter (lambda (x) (< 4 x)) ...

Ugh!  I don't think this is nice at all.  With the explicit name, you have
some symmetry:
(lambda (x) (< 4 x))  <-->  (lambda (x) (> x 4))

  Which is lost:
                 (< 4)     <--/-->   (> 4)

and you lose n-ary functions,  and you lose argument count checking.

> So we suffer .. but it's not too bad.

I can live with this pain.
Whip me!  Beat me!  Make me write bad type checks!


-- 
~jrm


Posted on the users mailing list.