The Unix module defines the Unix_error exception constructor.

  1. module Unix : sig
  2. exception Unix_error of error * string * string
  3. ...
  4. end

Suppose you want to create your own My_unix module that defines some Unix utility functions and exports the same Unix_error. How would you do it? You can't redeclare

Unix_error, since that would make a new constructor, which won't match Unix.Unix_error.

  1. module My_unix = struct
  2. exception Unix_error of error * string * string (* a new exception *)
  3. ... my unix functions ...
  4. end

You could include the whole Unix module, but that pollutes the namespace of My_unix unnecessarily.

  1. module My_unix = struct
  2. include Unix
  3.  
  4. ... my unix functions ...
  5. end

A trick to bring just the exception constructor you want into scope is to use a constrained include of the form include (M : sig ... end).

  1. module My_unix = struct
  2. include (Unix : sig exception Unix_error of Unix.error * string * string end)
  3.  
  4. ... my unix functions ...
  5. end

This does require duplicating the exception declaration in the signature, but the type checker will of course guarantee that the declaration you write matches the original, so there is no real chance for error.