Export wrapped modules with a restricted interface

I use dune and it default wrapping of modules which is nice.

I have a module A.ml with its interface A.mli, but when it is wrapped in the main module, I would like to use a restricted interface A_sub.mli, because only those functions are useful for the end user. Is there a way to do that or should I wrap my library myself ?

Indeed you can just write the main module and its interface yourself with

(** @canonical Main.A *)
module A = A

in main.ml and module A : sig ... end with the appropriate restricted signature in main.mli.

I don’t know if there is another option…

1 Like

Thanks, it worked nicely.

Would be even better it it could be build using annotation in the mli file, but they are a few case to handle

  • ommission
  • make a type private
  • ommit a type def