From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id LAA27253 for caml-redistribution; Wed, 27 Mar 1996 11:02:41 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id SAA26290 for ; Mon, 25 Mar 1996 18:22:21 +0100 From: pbrisset@eis.enac.dgac.fr Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.1/8.7.1) with ESMTP id SAA25215 for ; Mon, 25 Mar 1996 18:21:52 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.6.10/8.6.6) with ESMTP id SAA28190 for ; Mon, 25 Mar 1996 18:22:20 +0100 Received: from apollo12.eis.enac.dgac.fr (apollo12.eis.enac.dgac.fr [192.70.3.82]) by concorde.inria.fr (8.7.1/8.7.1) with SMTP id SAA25211 for ; Mon, 25 Mar 1996 18:21:51 +0100 (MET) Message-Id: <199603251721.SAA25211@concorde.inria.fr> Received: from apoge.eis.enac.dgac.fr by apollo12.eis.enac.dgac.fr with SMTP (1.37.109.4/17.1) id AA16527; Mon, 25 Mar 96 18:22:14 +0100 Received: by apoge.eis.enac.dgac.fr (1.38.193.4/16.2) id AA08810; Mon, 25 Mar 1996 18:22:09 +0100 Date: Mon, 25 Mar 1996 18:22:09 +0100 To: caml-list@margaux.inria.fr Subject: One more question about the module system Sender: weis Here is my problem: I have a program implemented in several files (say m.ml, m1.ml and m2.ml). This program depends on a module L and the dependency is expressed using the .mli/open mechanism. So I have: (* m.ml *) open L open M1 ... (* m1.ml *) open L open M2 ... (* m2.ml *) open L ... I want to transform this program in order to have a functor of argument L (i.e. I want to use twice my program with two different module L's). So I want to be able to write (in a main.ml): module ML1 = M(L1) module ML2 = M(L2) ... where M is the functor. I use the following idea: because my different (implicit) modules depend on L, I have to translate them into (explicit) functors. Then, I apply the functors for m1.ml and m2.ml in the main module defined in m.ml. The m1.ml module can no longer include an "open M2" since M2 is a functor: m1.ml have to speak about M2 through the instantiation of M2 done in M. So I start to write: (* m.mli *) module type L = ... module M(X : L) : sig module M1 : sig ... X.t ... end module M2 : sig ... X.t ... end val main : ... end (* m.ml *) module M(X : L) = struct module M1 = M1.Make(X) module M2 = M2.Make(X) (* previous m.ml *) let main = ... end (* m1.mli *) module type L = ... module Make(X : L) : sig type t1 = ... val v1 : M.M(X).M2.t2 ... end (* m2.mli *) module type L = ... module Make(X : L) : sig type t2 = ... val v2 : ... end For these files, it is OK but I cannot write m1.ml : (* m1.ml *) module type L = ... module Make(X : L) = struct (* previous m1.ml *) let v1 = ... M.M(X).M2.v2 ... ^^^^^^^^^^^^ end The underlined expression is not valid. So my idea does not work. Any hint to "functorize" my package ? -------------- Pascal Brisset ENAC, 7 avenue Edouard Belin, BP 4005, F-31055 Toulouse Cedex, France Tel: +33 62 17 40 53, E-mail: pbrisset@eis.enac.dgac.fr, Fax: +33 62 17 41 43