type declaration in */mli & *.ml

Basile STARYNKEVITCH (Basile.Starynkevitch@cea.fr)
Mon, 21 Oct 1996 11:23:25 +0200

Date: Mon, 21 Oct 1996 11:23:25 +0200
Message-Id: <199610210923.LAA01989@soleil.serma.cea.fr>
From: Basile STARYNKEVITCH <Basile.Starynkevitch@cea.fr>
To: caml-list@inria.fr
Subject: type declaration in */mli & *.ml

Hello All,

It seems that when a type is declared in the interface of a module Moo
-ie in the file moo.mli- it should also be declared in the
implementation of the same module Moo -ie in the file moo.ml-.

For instance, in directory ocaml-1.02/toplevel the file toploop.mli
contains

(*################ from toplevel/toploop.mli *)

(* Interface with toplevel directives *)

type directive_fun =
Directive_none of (unit -> unit)
| Directive_string of (string -> unit)
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)

(*############### end of sample ################*)

while the file toploop.ml also contains

(*############# from toplevel/toploop.ml ################*)

type directive_fun =
Directive_none of (unit -> unit)
| Directive_string of (string -> unit)
| Directive_int of (int -> unit)
| Directive_ident of (Longident.t -> unit)

(*################ end of sample ################*)

I don't understand why is it so, and I feel such a redundancy is very
annoying.

Any hints or explanations?

(perhaps I could paraphrase my question: does an implementation file
moo.ml of a module Moo contain an implicit open Moo;; ??)

Thanks for reading.

N.B. Any opinions expressed here are solely mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.

Please cite a *pertinent part* of my mail in all answers
Veuillez citer une *partie pertinente* de mon courrier dans vos reponses

----------------------------------------------------------------------
Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique
DRN/DMT/SERMA * CEA/Saclay bat.470 * 91191 GIF/YVETTE CEDEX * France
fax: (33) 01,69.08.85.68; phone: 01,69.08.40.66; home: 01,46.65.45.53
email: Basile.Starynkevitch@cea.fr (or else basile@soleil.serma.cea.fr);
I speak french, english, russian. Je parle français, anglais, russe.
----------------------------------------------------------------------