Referring to module types defined in top level files

In OCaml, if your project has a file named code.ml, you can reference it in other files using the Code module name. I was wondering if you defined the .mli file, if you could refer to the signature it defines in a similar way. For example, if you have a file wow.mli and you might have another file with a declaration

module Func(St : Wow) = struct ... end

      

Is there a way to do something along these lines?

+3


source to share


1 answer


This works for me:

module Func(St: module type of Wow) = struct ... end

      



More details here what I did:

$ cat wow.mli
val f : int -> int
$ cat m.ml
module Func (St: module type of Wow) = struct let f x = St.f x end
$ ocamlopt -c wow.mli
$ ocamlopt -c m.ml

      

+3


source







All Articles