News for hackers. Stuff that matters.
Re:What is the advantage of currying? by jerf on Saturday February 02, 2013 @10:23AM (#5156154)
There are some things in the world of programming or software engineering that are difficult to explain the cost/benefits of in a nice little blog post, because the costs or benefits don't become apparent in anything that fits in a blog post.

As you'd suspect from that lead-in, currying is one of those things. Explaining how it works is easy in a blog post, explaining why it is interesting is hard to do without being A: trivial or B: gibberish if you don't already know Haskell fairly well. Both approaches are taken in the StackOverflow there.

While it does mean you lose default and named args, it turns out to hurt less than you'd think, because the whole runtime and library is set up around functions without named args. I'm not sure exactly why, but when you can break things down into such smaller grained functions it seems to matter less. Positional is handled by a variety of functions that can reorder arguments, most commonly "flip" which switches the order of the first and second arguments, and while that is used and idiomatic it's probably used less than you'd think.

I can assure you it gets used a lot in idiomatic Haskell.

There are no comments on this comment yet.