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
[Caml-list] Legality of using module types from .mli in .ml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thorsten Ohl <ohl@p...>
Subject: [Caml-list] Re: Legality of using module types from .mli in .ml
Julien Signoles <> writes:

> The previous example doesn't break my defunctorizer :
> 	  $ ocamldefun --version
> 	  1.02
> 	  $ ocamldefun a.mli
> 	  $ cat
> 	  module type T = A.T
> 	  module M = struct let n = 42 end
> That's ok (normal because a.mli is still in the ocamldefun environment
> when is defunctorized)...

The O'Caml compiler will later not be able to resolve A.T if you use
the `-d' option:

    ohl@wptx47:~misc$ ocamldefun -v
    ohl@wptx47:~misc$ cat a.mli
    module type T = sig val n : int end
    module M : T
    ohl@wptx47:~misc$ cat 
    module type T = A.T
    module M : T = struct let n = 42 end
    ohl@wptx47:~misc$ ocamldefun -d defun a.mli
    ohl@wptx47:~misc$ cd defun/
    ohl@wptx47:~defun$ ls
    ohl@wptx47:~defun$ cat
    module type T = A.T
    module M = struct let n = 42 end
    ohl@wptx47:~defun$ ocamlopt
    File "", line 1, characters 16-19:
    Unbound module type A.T

I could ignore appendix B of the manual and create a a.cmi:

    ohl@wptx47:~defun$ cp ../a.mli . 
    ohl@wptx47:~defun$ ocamlc a.mli
    ohl@wptx47:~defun$ ocamlopt

but I'm not supposed to do that, am I?

BTW: given the (currently) uncertain semantics, I have started to
remove the construct from my applications.
Thorsten Ohl, Physics Dept., Wuerzburg Univ. --     [<=== PGP public key here]
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: