[rabbitmq-discuss] erlando question

Matthew Sackman matthew at rabbitmq.com
Tue May 10 17:35:46 BST 2011

On Tue, May 10, 2011 at 11:20:15AM -0500, Jon Brisbin wrote:
> Since there's not an Erlando list (that I'm aware of)

True. I don't think this is quite the right place for such questions
though - but there's nothing better atm. Whilst I am on erlang-questions
too, I don't really pay it much attention.

If people would like me to set up an erlando mailing list, just email
_me_ directly a "yes", and I'll see what I can do.

>, I thought I'd ask here. I'm trying to digest the new README on github
>and wondered: is the cut transform kind of like currying?

Yes, and it does say that right at the start of the README. Strictly, in
my mind partial application and currying are two different things.

(Sorry, I have to drop into Haskell here, otherwise the difference is
less clear.) Partial application is when you do

 f = (+) 5

and thus end up with f :: (Num a) => a -> a

The key thing is that you're partially applying the arguments in the
order that the occur specified by the function.

Currying, however, is the relationship between a function that takes,
say, 2 arguments, and a function that takes 1 argument which is a tuple
of 2 elements. So in Haskell, we have:

curry :: ((a, b) -> c) -> a -> b -> c

I.e. give it a function that takes a tuple, and it'll make it look like
a function that takes 2 args; and the opposite, uncurry:

uncurry :: (a -> b -> c) -> (a, b) -> c

I.e. give it a function that takes 2 args, and it'll make it look like a
function that takes a tuple.

In languages where parenthesis are required to distinguish between
functions and their arguments (i.e. not Haskell), this all looks a bit

Most people use currying and partial application interchangably.

Cuts are similar but actually a little more powerful as they allow you
to create holes _before_ known arguments rather than just after. E.g.

 F = wibble(_, 12, _),

which you can't do with partial application, as you can only partially
apply args left to right.


More information about the rabbitmq-discuss mailing list