Re: [Haskell-cafe] Haskell's currying and partial application

Duh, I made a typo in my previous emails, I did mean a -> (b -> c) and not a -> (b,c). But you guys quickly corrected that IMHO when reading http://haskell.org/haskellwiki/Currying a newbie like me cannot see the difference between currying and partial application... I quote the text: -------------------- "Currying is the process of transforming a function that takes multiple arguments into a function that takes just a single argument and returns another function if any arguments are still needed. In Haskell, all functions are considered curried: that is, all functions in Haskell take just single arguments. This is mostly hidden in notation, and so may not be apparent to a new Haskeller. Let's take the function div :: Int -> Int -> Int which performs integer division. The expression div 11 2 unsurprisingly evaluates to 5. But there's more that's going on than immediately meets the untrained eye. It's a two-part process. First, div 11 is evaluated and returns a function of type Int -> Int" -------------------- But that is partial application, not currying no... Later in the text tuples are mentioned, but the real definition of currying being -- Hope I get it right this time... curry :: ((a, b) -> c) -> a -> b -> c is not really clear from the article to me...
----- Oorspronkelijk bericht ----- Van: Henning Thielemann [mailto:lemming@henning-thielemann.de] Verzonden: dinsdag, juli 3, 2007 01:48 PM Aan: 'Peter Verswyvelen' CC: Haskell-Cafe@haskell.org Onderwerp: Re: [Haskell-cafe] Haskell's currying and partial application
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

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
IMHO when reading
http://haskell.org/haskellwiki/Currying
a newbie like me cannot see the difference between currying and partial application...
Better now?

Henning Thielemann wrote:
On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
IMHO when reading
http://haskell.org/haskellwiki/Currying
a newbie like me cannot see the difference between currying and partial application...
Better now?
Much better, IMO, although I still don't like the part with four examples of sections. Sure, sections are cool but they have nothing much to do with currying. Even if our binary operators were defined uncurried, we could have identical syntactic sugar for sections... Jules

Much better. Although I struggle a bit with the exercises ;) Let's see id :: a -> a curry :: ((a,b) -> c) -> a -> b -> c => curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b) So basically if f = curry id then f x y = (x,y) which means curry id = (,) something like this? Do I win a price now? ;) -----Original Message----- From: Henning Thielemann [mailto:lemming@henning-thielemann.de] Sent: Tuesday, July 03, 2007 3:21 PM To: Peter Verswyvelen Cc: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Haskell's currying and partial application On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
IMHO when reading
http://haskell.org/haskellwiki/Currying
a newbie like me cannot see the difference between currying and partial application...
Better now?

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
Let's see
id :: a -> a
curry :: ((a,b) -> c) -> a -> b -> c
=> curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b)
So basically if
f = curry id
then
f x y = (x,y)
which means
curry id = (,)
something like this?
You got it!
Do I win a price now? ;)
I hoped that nobody would care about the puzzle, thus I have not thought about a price so far. :-]
participants (3)
-
Henning Thielemann
-
Jules Bean
-
Peter Verswyvelen