caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Yaron Minsky" <yminsky@cs.cornell.edu>
To: <caml-list@inria.fr>
Subject: [Caml-list] Parameterizing multiple modules using functors
Date: Mon, 18 Aug 2003 10:40:00 -0400 (EDT)	[thread overview]
Message-ID: <21795.141.155.88.179.1061217600.squirrel@minsky-primus.homeip.net> (raw)

I've asked this question before, but never quite got a satisfactory
answer.  I'm hoping something has changed between now and then (maybe with
3.07?).

Here's the issue.  Consider a project consisting of multiple modules with
lots of interdependencies.   Imagine then that I want to add some
flexibility to the system by abstracting out some of the structure of the
system using a functor.  Thus, I start out with modules A, B, C, and I
want to parameterize all these modules, let's say by the same module X.  
So what I want is a version of the program where I can use A.F(X) intead
of A, B.F(X) instead of B, and so on.  The problem is that I want to allow
references between these modules.  Thus, B.F(X) needs access to A.F(X),
and C.F(X) needs access to both A.F(X) and B.F(X).  The question is, is
there a reasonable way to achieve this?

I can think of an unreasonable way.  I can write the relevant functors so
that they can be embedded in a unified module U as follows:

module U =
struct
   module A = A.F(X)
   module B = B.F(A,X)
   module C = C.F(A,B,X)
end

In other words, B and C and require in their functors explicit arguments
corresponding to the other modulse they need.  This works, but it's
awfully ugly, not least because you have to write down some awful module
signatures in B and C to make this work.

Is there any non-awful way to achieve this?  The absence of this kind of
feature makes the entire functor system seem much less attractive for
adding any large-scale genericity.

Yaron


-------------------
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:[~2003-08-18 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-18 14:40 Yaron Minsky [this message]
2003-08-18 14:53 ` Yaron Minsky
2003-08-21 14:36 ` Xavier Leroy
2003-08-21 21:34   ` Yaron 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=21795.141.155.88.179.1061217600.squirrel@minsky-primus.homeip.net \
    --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;
as well as URLs for NNTP newsgroup(s).