|
|
|
|
|
by hinkley
2926 days ago
|
|
I’m a little surprised you only got two answers, because I’m pretty sure the answer depends on how you look at the problem. Mine is this: A function has variance because the types of its inputs or outputs are in a hierarchy. An object type system (or I suppose even a functor system?) with generics might leverage variance to make sure that the behavior of its own methods is consistent with the Substitution Principle (LSP). And many people will tldr this into variance being the tool to give you a type system that is LSP compatible. But it’s all about the operations, consuming and emitting types. |
|