(1) Ocaml 4.14.0 contains an AST node [Pwith_modtype] for “module type” constraint, I can use it for the ppx I am writing, but I saw that there is no syntax for it ?
(2) Moreover, I miss constraints for module type definition to include some constraints within the definition itself
as it is in reality a module rec, I must include the full type and can not use a previously defined module type.
My AST is generating the following kind of code, with (2) ommited and (1) thanks to the AST node.
module type A =
(* I need a way to enforce that T.x : x )
module type T ( with type x = x (2)*)
module A : A with module type T = sig type x = x val x : x val i : int val b : bool end (* (1) *) =
type x = int
module type T = sig type x = x val x : x val i : int val b : bool end
The syntax that you are using(?) is perfectly valid in OCaml 4.14 (without any ppx as described in the manual)
module type A= sig module type T end
module type B = A with module type T = sig type u end
It is however currently not possible to refer to module components defined inside the module type being constrained (which is a limitation shared with the
module constraint that maybe could be lifted?)
I am not sure what you are trying to achieve, but you can use an include to achieve a similar result:
module type A = sig
module type T
module type S = sig
include (A with type t := t and module type T = sig type x = t end)
Thanks! I was look at the wrong section of the manual … mod-constraint is extended at too many places in the manual.
And thank for the “include … with” that is probably going to be useful