Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: parameterized signatures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: parameterized signatures

> Is there a way to refer to the type of a functor defined by a .mli file
> in another .mli file?

> =====> the problem area. How do I express the type of this module?
> module type Wgraph = Pgraph.S ???

Acessing .mli-files as signatures is currently not possible. If I remember
right, I have already asked once whether this could be allowed, but I was
told that this would cause confusions about module names and module-type

Therefore, if I use functors I normally do not use an .mli-file to restrict
the interface, but split up the code in something like:

and restrict the modules/functors explicitely.

"" contains, for example:

  module type SPEC = sig ... end
  module type T = sig ... end

and "":

  open Foo_intf

  module Make (Spec : SPEC) : (T with ...) = struct ... end

Sometimes it is necessary to "reexport" types from the "specification"

Then I do this like:

  module Make (Spec_ : SPEC) : (T with ...) = struct
    module Spec = Spec_
    open Spec

Of course, the signature T will then have to include something like:

  module type SPEC = sig ... end

  module type T = sig
    module Spec : SPEC
    open Spec

and will thus make available all types in "Spec".

I hope this helps!

Best regards,
Markus Mottl

Markus Mottl,,