Live data from Hacker News

Trine – A utility library for functional programming in JavaScript

github.com

1–10 of 116 posts

Re: Trine – A utility library for functional programming in JavaScript

#4
Looks interesting, especially in concert with the proposed bind syntax. Fortunately, that syntax is in Babel now, so we can play with these ideas straight away.

That being said, the readme did not address why Ramda uses the data as the last parameter and not as `this`: To facilitate partial application.

Re: Trine – A utility library for functional programming in JavaScript

#6
post #2

What Javascript needs is a way to deterministically (re)run it, so that errors can be traced.

What's stopping you from doing that, exactly?

He's probably having issues with async gubbins. Some sort of 'rewind time' in the debugger so you could determine what happened when to get to this state of error.

Re: Trine – A utility library for functional programming in JavaScript

#7

Looks interesting, especially in concert with the proposed bind syntax. Fortunately, that syntax is in Babel now, so we can play with these ideas straight away. That being said, the readme did not address why Ramda uses the data as the last parameter and not as `this`: To facilitate partial application.

Ramda actually uses data as the last parameter usually, whereas lodash has it as the first.

However, I agree, the readme doesn't quite show the full power of Trine. Trine has `partial`, which allows you to do partial application as so: `parseInt::partial(_)`, that would create a function that acts as parseInt but only takes one argument. This is in sync with the partial application syntax proposal: https://gist.github.com/anonymous/5c4f6ea07ad3017d61be

The rest of the functional goodness, such as autocurrying are still undecided upon because in my personal experience autocurrying in JS is awkward and leads to bugs that are hard to debug. I'm also considering compose and a combination of compose and partial (e.g. apply a function to a parameter at a certain place), but again subjectively, composing functions like that has reduced the readability of codebases. JS already has first class functions which allows composition pretty easily, the only problem is that it's overtly verbose - I'm still hoping to see the single arrow function land in JS some day. :)

Re: Trine – A utility library for functional programming in JavaScript

#8

Looks cool. Not sure I get why installing `babel-runtime` would be something you'd have as a separate install step though, since there is no guarantee that the user would install the right version.

This is to avoid multiple versions of Trine required by libraries (or the application itself requiring a different version of babel-runtime) causing the different versions of `babel-runtime` to be included multiple times, which would be a problem especially for browser applications. Trine itself is very small, but if each module introduces a dependency to babel-runtime, it would be another case of "npm downloads the whole internet". :/

Re: Trine – A utility library for functional programming in JavaScript

#10
post #9

One downside of passing data as `this` that isn't mentioned is you can't use the concise function syntax `=>`. If we ever get thin arrows this problem will go away.

Right on the point. I'm still hoping for that to get in at some point. :)
Post reply on HN