News for hackers. Stuff that matters.
Re:A generically typed pipe function in TypeScript by teaearlgraycold on Sunday August 07, 2022 @01:16PM (#32378002)
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)
Re:A generically typed pipe function in TypeScript by harg on Monday August 08, 2022 @04:51AM (#32383508)
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

Re:A generically typed pipe function in TypeScript by ledauphin on Sunday August 07, 2022 @08:21PM (#32381252)
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.
Re:A generically typed pipe function in TypeScript by sfvisser on Sunday August 07, 2022 @01:17PM (#32378009)
Yes, more akin to what you’d normally call ‘compose’. Fun stuff nonetheless!
Re:A generically typed pipe function in TypeScript by crooked-v on Sunday August 07, 2022 @07:17PM (#32380871)
`compose` would actually imply

  compose(fourth, third, second)(first)
Re:A generically typed pipe function in TypeScript by mo_po2 on Sunday August 07, 2022 @01:39PM (#32378163)
I agree. Calling it pipe adds confusion to FL understanding for newcomers.
Re:A generically typed pipe function in TypeScript by ledauphin on Sunday August 07, 2022 @08:21PM (#32381256)
pipe is a left to right compose. this is standard nomenclature in many similar libraries.