I don't think that you can currently do this.  According to the manual entry for GADTs: "This return type must use the same type constructor as the type being defined, and have the same number of parameters."

But I guess it would be a supportable feature to perform type substitutions until the above is satisfied if at all possible.  Substituting manually is probably the only thing you can do until then.

On Fri, Jun 15, 2018 at 10:35 AM Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
Hello,

I'm trying to write the following:

#+begin_src ocaml
type state
type value
type literal

type (_,_)  term =
  | Skip : (state, state) term
  | Const : literal -> (state, value) term
  | If : expr * stat * stat -> (state,state) term
and expr = (state,value) term
and stat = (state,state) term
#+end_src

and it works well. However I would like to replace the right-hand side
with their abbreviations (stat and expr), and at that point the
typechecker complains. Is there a workaround?

Thanks,

Alan

--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2018-05: 411.25, 2017-05: 409.65


--
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com