News for hackers. Stuff that matters.
Re:A generically typed pipe function in TypeScript by btown on Sunday August 07, 2022 @01:38PM (#32378149)
If I'm reaching for this form, I'm likely thinking about a pipeline of unary functions, and the TC39 proposal seems to take the same approach. Plus, doesn't every other function in the pipeline need to be unary after the first?

As a half-baked thought, perhaps callPipe would take exactly one non-function argument to start the pipeline (which would appeal to most use cases), and applyPipe could take an array of args, mimicking the call/apply duality in native JS?

Re:A generically typed pipe function in TypeScript by upzylon on Sunday August 07, 2022 @01:47PM (#32378214)
Yes, every function except the first one needs to have exactly one argument.

Others have also said that `pipe` is not an ideal name for the function. So perhaps renaming it to `compose` and have `pipe` be of the form `pipe(arg, funA, funB, ...)` (like you suggested for `applyPipe`) might be the solution. Will need to think about it a bit more.

Re:A generically typed pipe function in TypeScript by anderskaseorg on Sunday August 07, 2022 @02:37PM (#32378615)
Note ‘compose’ conventionally connotes a right-to-left order, so that (f ∘ g ∘ h)(x) = f(g(h(x))).