caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Functorizing large collections of modules
@ 2002-03-18  4:09 Yaron M. Minsky
  2002-03-18  9:01 ` Remi VANICAT
  0 siblings, 1 reply; 9+ messages in thread
From: Yaron M. Minsky @ 2002-03-18  4:09 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-03-20 12:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-18  4:09 [Caml-list] Functorizing large collections of modules Yaron M. Minsky
2002-03-18  9:01 ` Remi VANICAT
2002-03-18 12:19   ` Yaron M. Minsky
2002-03-18 12:52     ` Sami Mäkelä
2002-03-19 23:27       ` Yaron M. Minsky
2002-03-19 23:44         ` Fermin Reig
2002-03-20  9:09         ` Francois Pottier
2002-03-20 11:24           ` Alain Frisch
2002-03-20 12:59             ` Yaron M. Minsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).