From: Claudio Russo <crusso@microsoft.com>
To: Frank Atanassow <franka@cs.uu.nl>
Cc: caml-list@inria.fr
Subject: RE: first class modules (was: alternative module systems)
Date: Tue, 9 Jan 2001 05:36:17 -0800 [thread overview]
Message-ID: <112C6E8A1B25D34BB27D48D2FD2E96CFC9DECE@TVP-MSG-02.europe.corp.microsoft.com> (raw)
Hi Frank,
This should do it...
signature S = sig type t; val x: t; val y: t -> int end;
functor F A:sig val b: bool end = struct
structure X as S = if A.b
then [structure struct type t = int;
val x = 0;
val y = fn x:t => x
end as S]
else [structure struct type t = int -> int;
val x = fn x:int => x;
val y = fn f:t => f 1
end as S]
end; (* X.t depends on the value of A.b *)
structure Y = F(struct val b = true end);
structure Z = F(struct val b = false end);
(* if functors are applicative then Y.X.t = Z.X.t *)
val z = Z.X.y (Y.X.x) (* applies 0 to 1, a run-time error *)
Note that the definition of z goes "wrong" if F is applicative (a la
O'Caml, and expressible in Mosml syntax by omitting the parenthesis
around A:sig ... end),
but is ill-typed if F is generative (as in Standard ML). The program is
rejected by the (crude)
syntactic restriction that functor bodies can't eliminate first-class
modules,
except within inner Core let expressions.
Section 7.4 of my thesis discusses this issue in detail. Xavier's paper
on applicative functors has a similar example. The example above appears
in my forthcoming Nordic Journal of Computation article.
Cheers,
Claudio
> -----Original Message-----
> From: Frank Atanassow [mailto:franka@cs.uu.nl]
> Sent: 09 January 2001 12:31
> To: Claudio Russo
> Subject: Re: first class modules (was: alternative module systems)
>
>
> Hello,
>
> Claudio Russo wrote (on 08-01-01 07:11 -0800):
> > This is actually more general (and convenient) than the
> open construct
> > because it lets you open first-class modules at top-level
> and within
> > structure bodies, not just within Core expressions. If functors are
> > always generative, this is ok, but it interacts badly with
> applicative
> > functors (programs can go "wrong").
>
> I have seen you allude to this type soundness issue several
> times now. Can you
> give an example of a bad program which violates your
> condition? (Or just
> point me to the place in your thesis or a paper where it is
> elucidated.)
>
> --
> Frank Atanassow, Information & Computing Sciences, Utrecht University
> Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
> Tel +31 (030) 253-3261 Fax +31 (030) 251-379
>
next reply other threads:[~2001-01-10 8:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-09 13:36 Claudio Russo [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-01-10 10:32 Claudio Russo
2001-01-08 15:11 Claudio Russo
2001-01-08 14:59 Claudio Russo
2001-01-08 13:48 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=112C6E8A1B25D34BB27D48D2FD2E96CFC9DECE@TVP-MSG-02.europe.corp.microsoft.com \
--to=crusso@microsoft.com \
--cc=caml-list@inria.fr \
--cc=franka@cs.uu.nl \
/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