Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Yaron M. Minsky" <yminsky@cs.cornell.edu>
To: caml-list@inria.fr
Subject: [Caml-list] Functorizing large collections of modules
Date: 17 Mar 2002 23:09:43 -0500	[thread overview]
Message-ID: <1016424584.26193.42.camel@dragonfly.localdomain> (raw)

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


             reply	other threads:[~2002-03-18  4:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-18  4:09 Yaron M. Minsky [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1016424584.26193.42.camel@dragonfly.localdomain \
    --to=yminsky@cs.cornell.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox