From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA24326; Mon, 18 Mar 2002 05:09:51 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA24061 for ; Mon, 18 Mar 2002 05:09:50 +0100 (MET) Received: from falcon.prod.itd.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g2I49nv26859 for ; Mon, 18 Mar 2002 05:09:49 +0100 (MET) Received: from user-0ccegg9.cable.mindspring.com ([24.199.66.9] helo=flapdragon.homeip.net) by falcon.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16moSu-0000iQ-00 for caml-list@inria.fr; Sun, 17 Mar 2002 20:09:44 -0800 Subject: [Caml-list] Functorizing large collections of modules From: "Yaron M. Minsky" To: caml-list@inria.fr Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.2 Date: 17 Mar 2002 23:09:43 -0500 Message-Id: <1016424584.26193.42.camel@dragonfly.localdomain> Mime-Version: 1.0 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm doing some work where I need a bunch of modules that use the same module ZZp for doing arithmetic module a given prime P. I wrote a functor MakeZZp that takes a prime p and returns a module for doing modular arithmetic over that prime. Here's the problem. I have a bunch of modules that depend on ZZp, and I would like them all to be able to reference the same instance of ZZp. One way of doing would be simply to functorize each and every one of them separately by ZZp. Then, every time one of these modules references another, the argument of ZZp would have to be passed on. Thus, rather than referencing Foo, you'd reference Foo.M(ZZp). This seems messy and kind of silly. Conceptually what I want is a single structure like this: module Library(ZZp:ZZpSig) = struct module Foo = struct ... end module Bar = struct ... end ... end That way, all the interior modules (Foo, Bar) get to reference the same ZZp, without having to functorize the individual modules. So, what I'd like is to be able to do this without sticking the modules Foo and Bar into the same single large unmanageable file. So, is there any way of doing this? Or am I just going about it wrong. Another solution, of course, would be to use no functors at all, and have a single module ZZp where the parameter (the prime) is mutable. But that seems both messy and less flexible. y -- |--------/ Yaron M. Minsky \--------| |--------\ http://www.cs.cornell.edu/home/yminsky/ /--------| Open PGP --- KeyID B1FFD916 (new key as of Dec 4th) Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916 ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners