Co-, contra-, and invariance20 Oct 2019 (Note: this is an entry in my technical diary. There will likely be typos, mistakes, or wider logical leaps—the intent here is to “[let] others look over my shoulder while I figure things out.”)
Folks often refer to the component of a functor’s “polarity.” “The input is in the negative position.” “The output is positive.”
And that made me wonder, is there a, well, neutral polarity?
Maybe that’s when a component is in both a negative and positive position, canceling one another out.
Let’s see what happens.
A -> ….
A is in a negative position? Check. Let’s add it to the positive spot.
A -> A.
This is our old friend,
Endo! At the bottom of the file, I noticed
imap and asked some folks what the “i” stood for. Turns out it’s short for, “invariant,” which reads nicely in that both co- and contravariance net out to invariance.
Pairing functor type, variance(s), and
- Functor, covariant,
- Functor, contravariant,
- Bifunctor, covariant (and I’m guessing contra-, maybe both working in the same direction is what matters?),
- Invariant functor, invariant (co- and contravariant in the same component),
- Profunctor, co- and contravariant along two components,