
Ah, thanks for the correction. So if I understand it correctly, this is currying: when f :: (a,b) -> c then g :: a -> (b,c) is the curried form of f? So currying has to do with tuples? And partial application is just leaving away some tail arguments?
----- Oorspronkelijk bericht ----- Van: Jules Bean [mailto:jules@jellybean.co.uk] Verzonden: dinsdag, juli 3, 2007 12:19 PM Aan: 'peterv' CC: Haskell-Cafe@haskell.org Onderwerp: Re: [Haskell-cafe] Haskell's "partial application" (not currying!) versus Business Objects Gem Cutter's "burning"
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

Peter Verswyvelen wrote:
Ah, thanks for the correction. So if I understand it correctly, this is currying:
when
f :: (a,b) -> c
then
g :: a -> (b,c)
is the curried form of f? So currying has to do with tuples?
g :: a -> b -> c (also could be written as g :: a -> (b -> c) ) is the curried form of f. Curry has to do with the isomorphism between tuples, and functions-returning-functions.
And partial application is just leaving away some tail arguments?
Depending how generally you want to construe it; you might say "partial application is leaving off tail arguments" or "partial application is leaving off some arguments". Currying makes partial application "easier". Jules

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
Ah, thanks for the correction. So if I understand it correctly, this is currying:
when
f :: (a,b) -> c
then
g :: a -> (b,c)
is the curried form of f?
No it is g :: a -> b -> c g = curry f
So currying has to do with tuples?
Yes.
And partial application is just leaving away some tail arguments?
Indeed.

On Tue, Jul 03, 2007 at 10:53:33AM +0000, Peter Verswyvelen wrote:
Ah, thanks for the correction. So if I understand it correctly, this is currying:
when
f :: (a,b) -> c
then
g :: a -> (b,c) g :: a->b->c
is the curried form of f? So currying has to do with tuples?
And partial application is just leaving away some tail arguments?

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
Ah, thanks for the correction. So if I understand it correctly, this is currying:
See also: http://haskell.org/haskellwiki/Currying http://haskell.org/haskellwiki/Partial_application and more generally: http://haskell.org/haskellwiki/Category:Glossary
participants (4)
-
Henning Thielemann
-
Ilya Tsindlekht
-
Jules Bean
-
Peter Verswyvelen