Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interfaces have variance too, as long as they give rise to a subtyping relationship (which, in most languages that have them, they do).


Ha! Cunningham's law.

I see that many OOP languages (of various purity) have interfaces that may be extended by other interfaces. Is that what you're talking about?

I also found that *variance is used in the context of Haskell, but it seems to be far from being widely used.

Haskell being my template of a language with a good-looking interplay of polymorphism and algebraic typing.


variance is used in Haskell all the time. Haskell's subtyping/type-subsumption relation is less pervasive than an OO language's, but it's critical. Furthermore, variance is more fundamental than subtyping. It is not at all a stretch to say that the type mechanics of function composition are based on contravariance/covariance matching.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: