Idiomatic HKTs and Variadic Generic Types #45438
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
Suggestion
Pertaining to the discussion in #1213 and having looked at similar suggestions (borrowing ideas where appropriate), this is a strawman proposal (syntax only) on HKTs and Variadic Generic Types that adheres to existing syntax and mindset in JS/TS , hence named "idiomatic".
🔍 Search Terms
HKT
Higher Order Types
Higher Kinded Types
Higher Order Type Functions
Higher Order Function Generic
Variadic Generic Types
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Higher Kinded Types
Suggested syntax:
Properties
f(x)(y)(z)
Variadic Generic Types
Suggested syntax:
Properties
📃 Motivating Example
I was looking at the code in the
streaming-iterables
package, the pattern of defining an_fn
and then overloading it with anfn
including a curried version seems a case of DRY, happens in all functions the package exposes.Below code was my attempt at a general currying overload implementation for the package:
This works well until
generics
come into play:SO Question
💻 Use Cases
Using this proposal, the example described in the previous section can be covered:
The text was updated successfully, but these errors were encountered: