Covariance and contravariance (computer science): Difference between revisions

Content deleted Content added
m OCaml does not permit types to be capitalized.
Line 15:
== Formal definition ==
{{More citations needed section|date=November 2021}}
Suppose <code>A</code> and <code>B</code> are types, and <code><nowiki>TI<U></nowiki></code> denotes application of a [[type constructor]] <code>TI</code> with type argument <code>U</code>.
Within the [[type system]] of a programming language, a [[typing rule]] for a type constructor <code>I</code> is:
* ''covariant'' if it preserves the [[subtyping|ordering of types (≤)]], which orders types from more specific to more generic: If <code>A ≤ B</code>, then <code>I<nowiki><A> ≤ I<B></nowiki></code>;