[Haskell-cafe] Haskell's "partial application" (not currying!) versus Business Objects Gem Cutter's "burning"

Jules Bean jules at jellybean.co.uk
Tue Jul 3 06:19:10 EDT 2007


peterv wrote:
> In Haskell, currying can only be done on the last (rightmost) function 
> arguments.


You are talking about partial application, not currying.

> foo x y
> 
> can be curried as
> 
> foo x
> 
> but not as
> 
> foo ? y
> 
> where ? would be a “wilcard” for the x parameter.

(\x -> foo x y)

[snip]

> This burning looks more general to me, but cannot be done using the 
> textual approach?

Well, it can be done, but basically there are two issues:

1. You need to demarquate the 'scope' of the ?. What 'lump' of 
expression is the partially evaluated part. An obvious way to do this is 
with parentheses, but you have to be careful.

2. If you have more than one ?, you need to remember which is which. 
Think of nested expressions, nested ?s. What if you want to use the 
'same' ? more than once?

The solution that haskell chooses to (2) is to 'label' the ?s with 
names. The solution to (1) is to mark the scope with a \, and the list 
of names bound:

\x z ->  foo (foo x y) z

Jules




More information about the Haskell-Cafe mailing list