3 ms·
The terminology is borrowed from category theory. The partially ordered set of types can be seen as a category where the points are the types and the arrows are
by qsort 6y ago
The terminology is borrowed from category theory. The partially ordered set of types can be seen as a category where the points are the types and the arrows are the is-a relation.
In this setting, a covariant/contravariant type constructor is a covariant/contravariant endofunctor.
- bryan0 6y agoOk thank you for this comment. I think maybe the clearer thing about categories (if I understand this right) is that the focus for covariance/contravariance is simply on the direction of the arrow. And yeah looking at the OP if you just look at the ascii diagram and the arrows it does actually seem clearer to me than the written description which seems completely confusing. but this terminology is still confusing (to me at least) and something i mentioned on another comment regarding covectors: "Contravariant functors are also occasionally called cofunctors" (https://en.wikipedia.org/wiki/Functor#Covariance_and_contravariance https://en.wikipedia.org/wiki/Functor#Covariance_and_contrav...) I guess maybe the what's confusing is that yes, it's clear these are opposites, but it's not always clear which is the original and which is dual.
- qsort 6y agoYeah, it's definitely about the "direction". I also agree with you that the OP is yet another "monads are burritos" kind of tutorial. Unfortunately it's a difficult concept to grasp and everyone has to think through it by themself in order to "get" it.