Contravariance
Contravariance is a concept in type systems describing how subtyping interacts with type constructors in contravariant positions, most notably function parameter types. It contrasts with covariance, where subtyping is preserved, and with invariance, where no substitution is allowed. In practical terms, contravariance governs how the type of a value used as a function argument relates to subtyping.
A common way to illustrate contravariance is with function types. If A is a subtype of B
Contravariance is particularly visible in the typing of callbacks, delegates, and consumer-like abstractions where the type
In summary, contravariance reverses the usual subtyping direction for types in input positions, ensuring that more