4 ms·
My quick and dirty tl;dr: https://gist.github.com/pathikrit/a7845f72645159646fdb632bc334771a https://gist.github.com/pathikrit/a7845f72645159646fdb632bc3... Le
by pathikrit 9y ago
My quick and dirty tl;dr:
https://gist.github.com/pathikrit/a7845f72645159646fdb632bc334771a https://gist.github.com/pathikrit/a7845f72645159646fdb632bc3...
Let C<A> be a higher-kinded type e.g. in List<Animal>, List is C and Animal is A.
Let S be a subtype of T e.g. in class Cat extends Animal, Cat is S and Animal is T
If C<S> is a subtype of C<T>, then C is covaraint on T e.g. List<Cat> is a subtype of List<Animal>
If C<T> is a subtype of C<S>, then C is contravariant on T e.g. Predicate<Animal> is a subtype of Predicate<Cat>
If neither C<T> and nor C<S> are subtypes of the other, thenC is invariant on T