logoalt Hacker News

kccqzytoday at 3:36 AM3 repliesview on HN

> What folks should actually be asking is “Does my language need generics?”.

You should also ask “Does my language need subtyping such as subclasses?” And if the answer to both is yes, you should probably forget about Hindley Milner, or at least pick something far away from it on the spectrum.


Replies

nextaccountictoday at 8:56 AM

In this case do yourself a favor and use something like simple-sub

https://github.com/LPTK/simple-sub

https://www.reddit.com/r/ProgrammingLanguages/comments/hpi54...

https://dl.acm.org/doi/10.1145/3409006

show 1 reply
derriztoday at 5:27 AM

HM handles sub-typing just fine? Numerous approaches have been known since the 1980s - Michael Wand’s row polymorphism is one such approach.

https://en.wikipedia.org/wiki/Row_polymorphism

show 3 replies
Joker_vDtoday at 4:30 AM

Eh, generics kinda do introduce a subtyping relation already. It's just that HM's Gen rule of e: σ implies e: ∀α.σ is restrictive enough that this subtyping relation can be checked (and inferred) by using just unification which is quite an amazing result.