caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Claudio Russo <crusso@microsoft.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>,
	Alain Frisch <frisch@clipper.ens.fr>
Cc: Caml list <caml-list@inria.fr>, sestoft@dina.kvl.dk, kfl@it.edu
Subject: RE: first class modules (was: alternative module systems)
Date: Mon, 8 Jan 2001 05:48:41 -0800	[thread overview]
Message-ID: <112C6E8A1B25D34BB27D48D2FD2E96CFC9DECB@TVP-MSG-02.europe.corp.microsoft.com> (raw)

Hi again,

> > a few month ago, Markus Mottl pointed to this mailing list 
> the work by
> > Claudio Russo on first class modules. There were no answer 
> about plans to
> > implement such a system for OCaml.
> 
> Well, it seems like Russo's first-class modules could be added with
> relatively little effort, if there is a sufficient need for them.
> (In OCaml and also in Luc Maranget's Hevea, I can see the need for
> conditionally selecting between several structures having the same
> signature; first-class modules give almost this but not quite.)

Why can't you do this with first-class modules?
In Moscow, you can write (note the somewhat different syntax designed to
co-exist with SML):

structure X as S = if toss_coin() then [structure Foo as S] else
[structure Bar as S];

It's a little redundant, but works.
If you want this to appear as a top-level or nested structure
declaration, then this does rely on 
integrating open with ordinary declarations,  but this is
straightforward.

> > As I see it, the main issue is the unification problem < S 
> > = < T >.
> 
> Right.  The last time we met, I asked Claudio about type inference
> issues for his scheme.  Basically, to "unify" <S> and <T>, you just
> check that the module types S and T are equivalent (using the same
> notion of equivalence that OCaml currently uses to for checking
> compatibility between manifest module type declarations, see 
> the predicate
> Includemod.check_modtype_equiv in the OCaml sources).
> 
> If <S> and <T> contain value components with non-generalized type
> variables, it is necessary to unify them along the way, and Claudio
> alluded to potential traps here.  However, I'm not even sure this can
> happen at all in OCaml since module types cannot contain n-g type vars
> and "pack" requires an explicit module type constraint.

This isn't quite true (unless you don't allow n-g vars in inferred
module types either).
Counter-example:

fun f x = [structure struct val y = x end as sig val y:int end];
> val f = fn : int -> [{val y : int}]

applying the constraint should affect the type of x (which will be a
free var until the 
signature is matched against).

FYI, in Moscow you can even write, 

fun f (x:'a) = [structure struct val y = x end as sig val y:'a end];
> val 'a f = fn : 'a -> [{val y : 'a}]

so that f is polymorphic.
> 
> > (as a side effect, we get the local "open ... in ...")
> 
> I'm not sure I follow you here.  Did you mean that "open" and "pack"
> subsume "let module ... in ..."?  This I agree with.

I think the best approach is the other way around, treating open as
another form of declaration.

Cheers,
Claudio
 
> - Xavier Leroy
> 



             reply	other threads:[~2001-01-08 17:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-08 13:48 Claudio Russo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-01-10 10:32 Claudio Russo
2001-01-09 13:36 Claudio Russo
2001-01-08 15:11 Claudio Russo
2001-01-08 14:59 Claudio Russo
2001-01-08 10:45 Claudio Russo
2001-01-08 12:17 ` Alain Frisch
2001-01-07  0:20 Alain Frisch
2001-01-07 23:26 ` Markus Mottl
2001-01-08 10:42 ` Xavier Leroy
2001-01-10  0:40   ` Brian Rogoff

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=112C6E8A1B25D34BB27D48D2FD2E96CFC9DECB@TVP-MSG-02.europe.corp.microsoft.com \
    --to=crusso@microsoft.com \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=frisch@clipper.ens.fr \
    --cc=kfl@it.edu \
    --cc=sestoft@dina.kvl.dk \
    /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).