Hello, I was playing around with polymorphic variant in gadt. And I get some problem with subtyping.
i.e I have type
# type int_ = [ `Int ];; # type real = [ `Int | `Float ];;
With list, I can do
# let int_list : int_ list = ;; # (int_list :> real list);; - : real list = 
But I am unable to achieve the same thing with gadt.
# type _ t = | Int : int_ t | Real : real t;; # (Int :> real t);; Error: Type int_ t is not a subtype of real t The first variant type does not allow tag(s) `Float
I know if I replace
Int : int_ t with something like
Int : [> `Int] t, it will work. But if want to abstract the type, OCaml does not allow me to do
type int_ = [> `Int ]. Is there a way for me to get around this? Thank you.