Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One thing I didn't get about functional programming is planning the parameter order in advance for currying them later. Arrow functions may not look as neat as Haskells currying, but you can partially apply any parameter regardless of whether it's first or not, including separate properties of object parameters.


Defaulting to data-last gets you 80% of the way.

    fn = (a -> b) -> a
So your typical array mapping becomes

    list.map(to(v => v * 2))
All very contrived of course.

Ramda’s currying [0] gives you the _ param to play with the order. But I’ve come to the conclusion that currying in JS is rarely worth the effort. [1]

0 - https://github.com/ramda/ramda/blob/v0.28.0/source/__.js

1 - https://2ality.com/2017/11/currying-in-js.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: