Le jeu. 7 août 2014 à 23:06, Trevor Smith <trevorsummerssmith@gmail.com> a écrit :
Edwin,

Thank you for your response.

You are correct that the "val t" in my example should read "type t".

My main goal is one of readability: I want to have large swathes of the codebase only use the immutable interface. A few, but very few, parts of the codebase will use the mutable interface. Ideally, I want the developer reading the .mli files to quickly and easily understand what interfaces do what. The standard way of adding the type constraints add a lot of syntax and make it (slightly) harder to read. My entire question is sort of a nitpick.

Hi, I am not sure I understood your problem but I'll try to provide some info.

The standard way of adding "type constraints" is by just exposing the equality between types in the interface. In your case:

character.mli:
  type t = CharacterImpl.t
  val create : string -> t
  val name : t -> string

mCharacter.mli:
  type t = CharacterImpl.t
  val create : string -> t
  val name : t -> string
  val set_name : t -> string -> unit

Which is what express "CharacterSig with type t = CharacterImpl.t":
create a new signature by taking "CharacterSig" and replacing "type t" by "type t = CharacterImpl.t".