News for hackers. Stuff that matters.
Re:Composability: From Callbacks to Categories in ES6 by kccqzy on Sunday July 10, 2016 @02:57AM (#12064792)
How is this a new hell? This is some elegant, mathematics-derived abstraction.
Re:Composability: From Callbacks to Categories in ES6 by pron on Sunday July 10, 2016 @04:37AM (#12064968)
Elegance is in the eye of the beholder, and being mathematics-derived says nothing of its suitability for direct use by humans. Gödel numbering is also "mathematics-derived" but few people would regard it as particularly elegant or useful (it may be elegant in the mathematical purpose it serves, but not for engineering).
Re:Composability: From Callbacks to Categories in ES6 by scribu on Sunday July 10, 2016 @04:35AM (#12064962)
It will turn into a hell because JavaScript lacks Haskell's strong type system. The tooling will not give you early warning if you pass a plain function into a construct that expects a promise etc.
Re:Composability: From Callbacks to Categories in ES6 by homami on Sunday July 10, 2016 @06:03AM (#12065119)
That's very true. But on the other hand dynamic typing is what enables us to play with JavaScript and re-create many concepts from FP in plain JS. This is not easy in many strongly typed languages which their type system falls short of Haskell's (that supports ADTs, kinds, recursive types, etc.).
Re:Composability: From Callbacks to Categories in ES6 by scribu on Sunday July 10, 2016 @10:50AM (#12065751)
Yes, dynamic typing allows experimentation. But just because you can make JS look like Haskell doesn't mean it's the most effective way to get stuff done. You'd be better off writing Haskell and transpiling it, IMO.

Note that I'm talking about writing an entire application in this style, not just sprinkling categories here and there.

Re:Composability: From Callbacks to Categories in ES6 by joostdevries on Sunday July 10, 2016 @01:26PM (#12066310)
I'm a static types kindaguy. So I've rewritten some of this code using Typescript to see what that looks like.

https://github.com/joost-de-vries/typescript-ramda/blob/mast...

Re:Composability: From Callbacks to Categories in ES6 by cutler on Sunday July 10, 2016 @06:06AM (#12065125)
This killed it for me:

class Callback

.....

this.then = g => new Callback(callback =>

Can't we just keep OOP out of FP?

Re:Composability: From Callbacks to Categories in ES6 by homami on Sunday July 10, 2016 @06:40AM (#12065178)
Using class enables us to chain instances naturally in JS syntax, especially because JS lacks infix functions or custom operators. o1.then(f).then(g).run(cb)
Re:Composability: From Callbacks to Categories in ES6 by BinaryIdiot on Sunday July 10, 2016 @09:37AM (#12065516)
You can avoid the class syntax here and write a function to return the same if you prefer.