3 ms·
The Fourth Type of Variance
- acjohnson55 8y agoI read about this concept before, I think here: https://typelevel.org/blog/2016/09/19/variance-phantom.html https://typelevel.org/blog/2016/09/19/variance-phantom.html
- comex 8y agoAlso known as bivariance.
- jayd16 8y agoDoes Java's type erasure/wild cards count as bivariance/phantom variance?
- afranchuk 8y agoI too haven't seen invariance used much, however recently I had a case where my data type (in Haskell) encapsulated both serialization and deserialization from a base type, and in this case the only way to "convert" the data type's type parameter was with an invariant transformation. This turned out to be a very elegant way to define a type that could be converted to and from yaml (though both directions were optional), because then the data type also stored the specification of the expected yaml input(s) (since converting to and from other types won't change the original yaml representation).
- cvs268 8y agoOT: What's with the the .pizza domain? Any particular reason? I clicked half-expecting some math behind people's choice of toppings