Using module include in OCaml

Posted by Geoff on Stack Overflow See other posts from Stack Overflow or by Geoff
Published on 2010-05-05T21:00:05Z Indexed on 2010/05/05 21:08 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

In OCaml 3.11, I want to "extend" an existing module using the include directive, like so:

module MyString = struct
  include String
  let trim s = ...
end

No problem. But now I want to expose this module's type explicitly (i.e. in a .mli file). I want something like this:

module MyString : sig
  include String
  val trim : string -> string
end

But the include syntax is not correct because String refers to a module, not a module type (and the compiler does indeed barf). How can I refer to the module type for String here (without having write it out explicitly in a sig expression)?

Thanks!

© Stack Overflow or respective owner

Related posts about ocaml

Related posts about module