If I have a file A.mli containing a trivial signaturetype t = int and want to include this signature in a file include_A.mli as include A, the compiler complains Unbound module type A. Incidentically open A is accepted.
If I wrap the signature in a file AT.mli as module type T = sig type t end, I can include it in a file include_AT.mli as include AT.T.
Is this behaviour by design? Is this what the manual means by roughly in A compilation unit behaves roughly as the module definition?
The include directive in an .mli file expects a module type as argument; A is a module, hence the error message. You can do include module type of A instead (but read the caveats at OCaml - Language extensions).
A better way of sharing module signatures is to define an explicit module type in a separate file, eg
(* A_intf.ml *)
module type S =
type t = int
and then writing include A_intf.S in A.mli. This avoids using the module type of ... construction.
Thanks for the clarification. I had been under the impression that signature and module-type were interchangeable. An earlier thread about the interaction of strengthening and module type of scared be away from using it …