# Export wrapped modules with a restricted interface

**URL:** <https://discuss.ocaml.org/t/export-wrapped-modules-with-a-restricted-interface/12361>\
**Category:** Ecosystem\
**Created:** [June 9, 2023, 8:51am UTC](https://discuss.ocaml.org/t/export-wrapped-modules-with-a-restricted-interface/12361 "2023-06-09T08:51:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craff](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/craff/32/3281_2.png) [@craff](https://discuss.ocaml.org/u/craff)\
**Post date:** [June 9, 2023, 8:51am UTC](https://discuss.ocaml.org/t/export-wrapped-modules-with-a-restricted-interface/12361/1 "2023-06-09T08:51:07Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![bnguyenvanyen](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bnguyenvanyen](https://discuss.ocaml.org/u/bnguyenvanyen)\
**Post date:** [June 9, 2023, 9:21am UTC](https://discuss.ocaml.org/t/export-wrapped-modules-with-a-restricted-interface/12361/2 "2023-06-09T09:21:10Z")

</div>

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

```ocaml
(** @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…

---

<div class="post-metadata">

**Author:** ![craff](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/craff/32/3281_2.png) [@craff](https://discuss.ocaml.org/u/craff)\
**Post date:** [June 9, 2023, 9:41pm UTC](https://discuss.ocaml.org/t/export-wrapped-modules-with-a-restricted-interface/12361/3 "2023-06-09T21:41:23Z")

</div>

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
- …
