2 ms·
Sounds like function foo(f: function<T1, T2>(T1 x, T2 y), bindY: T2) { return (x) => f(x, bindY); } This will be type safe and return a function<T1>(T1 x). (D
by Too 10y ago
Sounds like function foo(f: function<T1, T2>(T1 x, T2 y), bindY: T2) { return (x) => f(x, bindY); }
This will be type safe and return a function<T1>(T1 x).
(Disclaimer to typos and erros for typing on my phone)
- Roboprog 10y agoSimilar to that, yes - you have a higher order function, "foo" in this case, that accepts a function as an argument, and returns another function. FWIW, you want to have an operation to bind the first (or first N) formal parameter to a value, and you want to be able to have an arbitrary number of remaining parameters. Whatever facility would be in place needs to allow for N remaining formal parameters, of various types, not merely do the ("generic" / templated / type-parameter) recipe for one additional parameter. I am not a Haskell or F# programmer, but maybe the TS team wants to look at what those languages do.