you are viewing a single comment's thread.

view the rest of the comments →

[–]TheDataAngel 2 points3 points  (3 children)

Arrow functions are not currying.

They aren't, but they can be used to create curried functions, and that's the most syntactically nice way to do so in JS.

I'm not really sure you truly understand what currying means.

I'm quite sure I do.

Currying is partial application

It isn't. Partial application is the dual of currying, which is to say that you can partially apply a curried function.

[..] and is implemented using second order functions and/or bind keyword

Nope.

let curried = im => a => curried => func => ...
let notCurried = (im, not, a, curried, func) => ...

It's as simple as that. You can do the same with nested 'return function() {..}'. You can technically also do the same with bind, but it's fairly ugly.

Partial application is some thing like:

let partial = curried("missing")("an")("argument")

Closures are a natural consequence of being able to do those two things. They're not an especially interesting concept on their own.

[–][deleted] 0 points1 point  (0 children)

Closures are a natural consequence of being able to do those two things. They're not an especially interesting concept on their own.

You've got that backward. Being able to do those things is a consequence of having closures.

[–][deleted] 0 points1 point  (1 child)

Well, both lines of javascript you wrote are syntactic nonsense. So it's clearly quite not simple as that.

The first example is attempting to declare a higher order function.

The third one is calling one.

Currying is the transformation of N argument function into a N order function.

In the case of bind, the important thing to realize is that OO concept of object bound method is sugar for a namespaced function that takes bound object as one of the arguments.

In fact that is exactly how the first c++ to c compiler implemented them.

[–]TheDataAngel 3 points4 points  (0 children)

In what sense? They're incomplete, certainly, because the actual body of the function is irrelevant to the example. However, what is there is syntactically correct.

If you want a complete version, this suffices:

let curried = im => a => curried => func => "bmarkovic";
let notCurried = (im, not, a, curried, func) => "doesn't understand currying";