Generics add a lot of complexity to the language, and is hard to get right. This is something we would like to add to the language at some point, but I would say that we're not close yet.
For example, one thing to consider is how to implement variance checking. Today, Pkl does not perform subtype checking, and this is not trivial because of type constraints.
@bioball commented on GitHub (Jun 10, 2024):
Generics add a lot of complexity to the language, and is hard to get right. This is something we would like to add to the language at some point, but I would say that we're not close yet.
For example, one thing to consider is how to implement [variance checking](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)). Today, Pkl does not perform subtype checking, and this is not trivial because of [type constraints](https://pkl-lang.org/main/current/language-reference/index.html#type-constraints).
We also have some [bugs with type parameters in the core language](https://github.com/apple/pkl/issues/405) that will need to be fixed before we can start to consider something like this.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @moritztim on GitHub (May 15, 2024).
But why?
@bioball commented on GitHub (Jun 10, 2024):
Generics add a lot of complexity to the language, and is hard to get right. This is something we would like to add to the language at some point, but I would say that we're not close yet.
For example, one thing to consider is how to implement variance checking. Today, Pkl does not perform subtype checking, and this is not trivial because of type constraints.
We also have some bugs with type parameters in the core language that will need to be fixed before we can start to consider something like this.
@joshqou commented on GitHub (Dec 13, 2025):
Ran into this limitation myself. Definitely would be an appreciated feature