I try to define my own type system using gadt. But it seems that is complex to mix both type system : mine and the ocaml one.
This tiny example did not compile:
type _ t =
| Or: _ t * _ t -> _ t
| Int : int t
| Float : float t
let a = Or (Int, Float) (*is ok*)
let (||) a b = Or (a, b)
let aa = Int || Float (*Error: '_a t, contains type variable that cannot be generalized*)
Using an operator make a difference. But how to exprime "don't care" if a choice between 2 types is not possible to be define. It could be nice if "('a | 'b) t" worked :) Should i use normal sum type, and make all type check by a function ?