
Hello, what is so great about "currying"? What are its uses, apart from letting one define functions with less parentheses? Many thanks. Phiroc

On Thu, Jan 18, 2007 at 11:00:26AM +0100,
phiroc@free.fr
what is so great about "currying"?
The name is very cool.
What are its uses, apart from letting one define functions with less parentheses?
Partial applications. http://fr.wikipedia.org/wiki/Curryfication

phiroc@free.fr skrev:
Hello,
what is so great about "currying"?
What are its uses, apart from letting one define functions with less parentheses?
Letting one apply them with less extra characters: add x y = x + y map (add 2) [1..5] instead of add (x,y) = x + y let add2 y = add(2,y) in map add2 [1..5] end (The last might not technically be partial application, but it serves the same purpose without using currying.) I believe it makes code shorter and more readable, but I do not believe it gives more power. / johan

what is so great about "currying"?
What are its uses, apart from letting one define functions with less parentheses? Well, from an academic viewpoint, it's very interesting to see a function defined as a composition of functions. From a practical viewpoint, it's just really handy. It saves you a lot of tedious typing, and that's basically what progamming languages are supposed to do. That's exactly what I love about haskell: it saves me from a lot of unnecessary typing. After all, I'm a lazy programmer ;)
-chris

Hi, Phiroc wrote:
what is so great about "currying"? What are its uses, apart from letting one define functions with less parentheses?
Chris Eidhof wrote:
it's just really handy. It saves you a lot of tedious typing
I agree. But I think there is more to it than that. Currying is more than just a way to make it easier to convert a function into a different function with a different number of parameters. The original function is *already* a function of any number of its parameters that you want, all at once. That way of thinking gives you a lot of power, while preserving compile-time type safety and crystal-clear readability. I think this is one of the ingredients that contribute to the gestalt "wow" feeling that many beginners experience when they first "get it" in Haskell - a sudden exhilarating, liberating feeling of expressiveness. Regards, Yitz

On 18/01/07, Chris Eidhof
That's exactly what I love about haskell: it saves me from a lot of unnecessary typing. After all, I'm a lazy programmer ;)
Lazy languages for lazy programmers 8)
On 18/1/2007, Johan Grönqvist
add x y = x + y map (add 2) [1..5]
Don't know if you know this, but infix operators like (+) are
functions too, and you can partially apply them using 'sections':
map (+2) [1..5]
It's only syntax, but this is one of the things I really like about Haskell.
--
Peter Berry
participants (6)
-
Chris Eidhof
-
Johan Grönqvist
-
Peter Berry
-
phiroc@free.fr
-
Stephane Bortzmeyer
-
Yitzchak Gale