Is there any way to hide a concrete type in signature only?

I have a ppx which generates some code based on the type structure, to the end user, I want to mark it as a private type, however, I want to still ask the type checker to check the type definition is okay. Here is the rewrite I tried in the first round:

type t = A | B [@@deriving ..]

after my ppx:

include (module type of struct  type t = A | B   end : sig end)
.. my generated code below 

So far so good, however, module type of is a bit limited, it does not play well with recursive modules (https://github.com/ocaml/ocaml/issues/9574), is there a better trick to achieve this?

Thanks

You could maybe use open struct (via Generalized open statements) instead of giving a signature:

include module type of struct
  open! struct
    type t = A | B
  end
end

This still relies on module type of which doesn’t play nice with recursive modules

Kevin Ji via OCaml <ocaml@discoursemail.com>于2020年6月2日 周二下午12:02写道:

If you only need to typecheck the definition, it seems simpler to translate the Pstr_type item into a Psig_type item?