|
|
|
|
|
by sizediterable
1682 days ago
|
|
I think variance can be simulated by typing the private field as an existing covariant/contravariant/invariant type class CovariantFoo<T> {
private phantom!: T
}
class ContravariantFoo<T> {
private phantom!: (_: T) => void
}
class InvariantFoo<T> {
private phantom!: (_: T) => T
}
(inspired by Rust [0])[0] https://doc.rust-lang.org/nomicon/phantom-data.html |
|
https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-ki...
https://cs.emis.de/LIPIcs/volltexte/2015/5231/pdf/21_.pdf