- Let
C<A>be a higher-kinded type e.g. inList<Animal>,ListisCandAnimalisA. - Let
Sbe a subtype ofTe.g. inclass Cat extends Animal,CatisSandAnimalisT
- If
C<S>is a subtype ofC<T>, thenCis covaraint onTe.g.List<Cat>is a subtype ofList<Animal> - If
C<T>is a subtype ofC<S>, thenCis contravariant onTe.g.Predicate<Animal>is a subtype ofPredicate<Cat> - If neither
C<T>and norC<S>are subtypes of the other, thenCis invariant onT - If both
C<T>andC<S>are subtypes of each other, thenCis phantom variant onT. This is possible in languages which support phantom types like Haskell
In Scala: