Covariance and Contravariance
Nice article, though I <i>think</i> you're mixing up subtypes and supertypes. Or I am. After reading that I no longer know if "Cat extends Animal" means that Cat is a subtype of Animal, or that it's a supertype of Animal.<p>E.g.<p><pre><code>  let f1: A -> B = ...
  let f2: C -> D = f1

  (...)
  Applied here, the above code works if A is a subtype of C, and if B is a supertype of D.
  Put concretely:

  let f1: Animal -> Animal = ...
  let f2: Cat -> Thing = f1
</code></pre>
So now Animal is a subtype of a Cat, and a supertype of Thing?<p>But I finally understand what covariance and contravariance means, so thanks!<p>--<p>Also, related, could somebody more proficient in English than I am help me understand which direction does the substitution go here?<p>"It says, in short, that an instance of a subclass can always be substituted for an instance of its superclass."<p>Is it "an instance of subclass can replace an instance of superclass", or "it can be replaced by"? Or is it context-dependent?<p>I ask because I'm not sure about the grammar aspect, and in my native language (Polish) we have a few ambiguities like that, which I sometimes jokingly write down with an arrow, e.g. "A can be ---substitutes for--> B" or "A can be <--substituted for-- B", to make it damn explicit which direction the word works.