Hacker News new | ask | show | jobs
by teaearlgraycold 1414 days ago
Only complaint here is on the function signature. Normally a pipe operator takes in arguments first and then sequential functions. This pipe function fixes the reverse ordering of nested function calls, but the starting inputs will always appear at the end.

You've gone from:

    fourth(third(second(first)))
to

    pipe(second, third, fourth)(first)
when you could have done

    pipe(first, second, third, fourth)
3 comments

I agree. This is what fp-ts's pipe[1] function does. It also has flow[2], which is basically a reversed compose.

[1]: https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe

[2]: https://gcanti.github.io/fp-ts/modules/function.ts.html#flow

this pattern is standard in my experience for function composition. You're creating a function first, which can later be used to derive a result from an input.
Yes, more akin to what you’d normally call ‘compose’. Fun stuff nonetheless!
`compose` would actually imply

  compose(fourth, third, second)(first)
I agree. Calling it pipe adds confusion to FL understanding for newcomers.
pipe is a left to right compose. this is standard nomenclature in many similar libraries.