▲ | nukifw 5 days ago | |||||||||||||||||||||||||
- You can use GADTs (https://ocaml.org/manual/5.2/gadts-tutorial.html) and indexes to give a concrete type to every constructors:
- You can use the structurale nature of polymorphic variants (https://ocaml.org/manual/5.1/polyvariant.html)
(Notice the difference between `>` and `<` in the signature?)And since OCaml has also an object model, you can also encoding sum and sealing using modules (and private type abreviation). | ||||||||||||||||||||||||||
▲ | ackfoobar 5 days ago | parent [-] | |||||||||||||||||||||||||
Oh if you use those features to express what "sum type as subtyping" can, it sure gets confusing. But it's not those things that I want to express that are hard to reason about, the confusing part is the additions to the HM type system. A meta point: it seems to me that a lot of commenters in my thread don't know that vanilla HM cannot express subtypes. This allows the type system to "run backwards" and you have full type inference without any type annotations. One can call it a good tradeoff but it IS a tradeoff. | ||||||||||||||||||||||||||
|