Covariance and contravariance explained without code
github.com
github.com
Func Arg Val represents a function type from Args to Vals
consider foo(func : Func a b)
The argument to the function foo must be assignable to (a subtype of) Func a b
What are those subtypes? We can find out by considering expressions involving the argument
bidentifer = func(avalue)
so func must be an object whose type is compatible with assignments from the avalue, so its argument type must be a supertype of a
while the assignment to bidentifier implies the return value must be assignable to the return type so it must be a subtype
therefore the subtypes of Func a b are the set of types Func (super a) (sub b)
this is the origin of the phrase be generous in what you accept and specific about what you return
thinking about whether bikes are vehicles and such doesn't really clarify anything. you have to actually think about the expressions you are trying to construct
Moving down the Func type hierarchy moves you up the Argument type hierarchy (contra) but moves you down the Return type hierarchy (co)
That definitely needs citation, as Postel's law seems to have come from TCP RFCs.
https://stackoverflow.com/questions/5709034/does-c-sharp-sup...
To speak generally, if two objects have a co-variant relationship, then when one goes up the other goes up as well.
If two objects have a contra-varient relationship, when one goes up, the other goes down.
I'm being a bit reductive, but that's how I understand it.
Covariance is when things vary in the same way; and contravariance is when they vary in opposite ways. This isn't even random math jargon; co/contra, vary, and ance are all standard english words/affixes being used for their normal meaning.
In my experience, what is difficult is understanding contravariant relationships; but that is not a problem of terminology.
As far as for tensor stuff, I think what is confusing to me at least, is that the components of standard vectors are contravariant, while their dual covectors are covariant. contravariant tensors raise indices and covariants lower them.
Anyway I'm glad this is clear to you but I find it confusing.
Although I wonder now if there is a mapping from the OO diagrams in the OP with Penrose Tensor notations where everything will just make sense....
edit: missing word
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_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.