From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 60A98BC0A for ; Thu, 15 Mar 2007 15:21:45 +0100 (CET) Received: from smtp.uibk.ac.at (lmr1.uibk.ac.at [138.232.1.142]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2FELiwv010541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 15 Mar 2007 15:21:45 +0100 Received: from smc.uibk.ac.at (smc.uibk.ac.at [138.232.1.226] c703350@smc.uibk.ac.at) by smtp.uibk.ac.at (8.13.8/8.13.1/F1) with ESMTP id l2FELhlo012939 for ; Thu, 15 Mar 2007 15:21:43 +0100 Received: from smc.uibk.ac.at (localhost [127.0.0.1] c703350@smc.uibk.ac.at) by smc.uibk.ac.at (8.13.8+Sun/uibk) with ESMTP id l2FELh2j029994 for ; Thu, 15 Mar 2007 15:21:43 +0100 (MET) Received: (from c703350@localhost) by smc.uibk.ac.at (8.13.8+Sun/8.13.8/Submit) id l2FELhkv029993 for caml-list@yquem.inria.fr; Thu, 15 Mar 2007 15:21:43 +0100 (MET) Date: Thu, 15 Mar 2007 15:21:42 +0100 From: Christian Sternagel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] module types and constraints in several layers Message-ID: <20070315142142.GD3236@pc6197-c703.uibk.ac.at> Mail-Followup-To: caml-list@yquem.inria.fr References: <20070315101236.GB3236@pc6197-c703.uibk.ac.at> <875c7e070703150625r2fe44739r86755099a2bd2594@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875c7e070703150625r2fe44739r86755099a2bd2594@mail.gmail.com> User-Agent: Mutt/1.4.2.2i X-Scanned-By: MIMEDefang 2.58 at uibk.ac.at on 138.232.1.140 X-Miltered: at concorde with ID 45F95678.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; compiler:01 o'caml:01 submodules:01 submodules:01 compiler:01 struct:01 struct:01 functors:01 functors:01 mli:01 mli:01 sig:01 val:01 bool:01 val:01 On Thu, Mar 15, 2007 at 08:25:08AM -0500, Chris King wrote: > On 3/15/07, Christian Sternagel wrote: > >but I was not able to tell the compiler (correctly) that after > >building module E ist should be the case that for example > >E.E1 = D.D1 = B.B1 = A = E4.D.D1 = E4.D.D2.B1 = ... > > > >Is there a convenient way to make such a structure of modules? > >And if yes, how ist it done? > > What's happening is that, when you specify the type of the results of > B.Make and D.Make, O'Caml throws away the info about how they were > created: since the type signatures B.T and D.T simply say "these > modules have some submodules" but don't say where the submodules come > from, that info becomes hidden (as it should be). However you can > explicitly instruct the compiler not to hide this info: > > module Make (A : A.T) : B.T with module B1 = A = struct > ... > module B1 = A > ... > end > > This just says "give the resulting module the signature B.T, but > retain the info that module B1 equals A". Similarly: > > module Make (B : B.T) (C : C.T) : D.T > with module D1 = B.B1 and module D2 = B > = struct In fact thats exactly what I did, but it only worked when a had not more than 1 layer of functors applied to functors. I may need to give my actual program structure in more detail in order to explain my problem better. variable.mli: module Make (Id : IDENT.T) : VARIABLE.T with module Id = Id function.mli: module Make (Id : IDENT.T) (Lab : LABEL.T) : FUNCTION.T with module Id = Id and module Lab = Lab term.mli: module Make (Var : VARIABLE.T) (Fun : FUNCTION_SYMBOL.T) : TERM.T with module Var = Var and module Lab = Fun.Lab and module Fun = Fun TERM.mli: module type T = sig type t module Fun val f1 : t -> t -> bool val f2 : t -> t val f3 : Fun.t Setx.set -> t -> t end rule.mli: module Make (Term : TERM.T) : RULE.T with module Var = Term.Var and module Lab = Term.Lab and module Fun = Term.Fun and module Term = Term trs.mli: module Make (Rule : RULE.T) : TRS.T with module Var = Tule.Term.Var and module Lab = Rule.Term.Lab and module Fun = Rule.Term.Fun and module Term = Rule.Term and module Rule = Rule TRS.mli: module type T = sig type t module Fun : FUNCTION.T val f0 : t -> Fun.t Setx.set end everythin compiles fine. Then I make the following in another file. some.ml: module Make (Trs : TRS.T) : SOME.T = struct module Var = Trs.Var module Lab = Trs.Lab module Fun = Trs.Fun module Term = Trs.Term module Rule = Trs.Rule module Trs = Trs ... let ds = Trs.f0 trs in Term.f1 (Term.f2 (Term.f3 d s)) t ^ ... end end try to compile an the resulting error message is: This expression has type Trs.Fun.t Setx.set but is here used with type Term.Fun.t Setx.set Type Trs.Fun.t = Trs.Fun.t is not compatible with type Term.Fun.t = Trs.Term.Fun.t where the ^ markes the ment expression cheers christian > ... > module D1 = B.B1 > module D2 = B > module D3 = C > ... > end > > You don't need to do this with E.Make since its signature is left intact. > > You can do this with individual types too, see section 6.10 of the manual. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >