Re:Generalized Algebraic Data Types: A Primer
by anuragsoni on Tuesday June 18, 2019 @10:46PM
(#20220410)
FWIW OCaml (the linked example is using reason, a different syntax for OCaml) doesn't need a syntax extension for GADTs.
On a similar note i find the OCaml syntax easier to read than Reason's. (There is an option to toggle between the two in the linked website)
The example from your post in OCaml:
type 'a restricted_maybe =
| JustInt : int -> int restricted_maybe
| JustString : string -> string restricted_maybe
| Nothing : 'a restricted_maybe
It might also be a good idea to make note of where the polymorphism is happening (the "a") and note how it's ok that the a is "resolved" in some of these constructors but not in the others.
[0]: https://limperg.de/ghc-extensions/#gadts