Hacker News new | ask | show | jobs
by efdb 1912 days ago
i really like the syntax, very intuitive use of ->
1 comments

I wonder if there’s such a thing as intuitive syntax.

As far as I can see, the arrow signifies function application. Why do you consider “a -> f” more intuitive than, say, “f(a)” or “f a”?

because a -> f -> g -> h is better than h(g(f(a))). It is the functional way of doing the OOP fluent builder pattern: a.f().g().h()

It is the pipe operator (F#, Elixir, Haxe, etc.). There is a proposal to add it to js too.

On top of that, it is a symmetrical to fat arrow functions, which is a shorthand for lambda:

fun: x => x * 2

res: 4 -> fun

I have always used ramdajs for this.

const R = require('ramda');

R.pipe(a,f,g,h)