3 ms·
This is just a guess, but since TS is structural and it's inference engine is based on pattern matching instead of constraint solving some of this already appli
by wwwigham 8y ago
This is just a guess, but since TS is structural and it's inference engine is based on pattern matching instead of constraint solving some of this already applies. Minimally, the generalized type traversal constructors described as a use for higher kinds are already possible.[1] Then again, it was _also_ already similarly possible in Haskell, just _incredibly_ verbose, as it is there. The concepts don't quite transfer 1:1, due to implementation and type system differences (for example, TS doesn't have a solver relying on certain identities holding to generate new inferences or equations), but I think the gist of it (adding what amounts to a "is possibly a higher kind" constraint) could be portable and form the basis of a higher-kinded algebra in TS and allow for a wider array of patterns to be expressed more succinctly. Unfortunately I'm not immediately sure how structural subtyping would work out for something with that kind of constraint, which would need to be solved, too.
[1] https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ramda/tools.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...