From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Type constraints
Date: Wed, 8 Dec 2004 17:10:56 +0100 [thread overview]
Message-ID: <20041208161056.GA703@yquem.inria.fr> (raw)
In-Reply-To: <74A16EF6-4907-11D9-8195-000D9345235C@inria.fr>
> Hmmm... Now I don't know whether it's safe or not, and I don't know
> whether someone checked its safety before excluding it from the value
> restriction code...
You word it in a slightly backward way: it is always safe to claim
that an expression is expansive and its type should not be
generalized; it's the converse (asserting that an expression is
non-expansive) that is potentially dangerous and requires some
semantic evidence that it is safe. The current treatment of "let
module" as being always expansive just errs on the safe side, in the
absence of this semantic evidence.
> >So I don't understand why the same cannot apply to local modules. If
> >the let-module-in were declared "safe" for the value restriction,
> >shouldn't
> >
> >let module M = struct let v = ref [] end in M.v
> >
> >yield a non-generalized type for the same reason as for the non-local
> >case (and not because of the value restriction) ?
I don't follow you here. So, OK, your expression E above
(E = let module M = struct let v = ref [] end in M.v) has type
alpha list ref for a fresh variable alpha. If we were to classify E
as non-expansive, we could do
let x = E in E'
and in E', x would have polymorphic type forall alpha, alpha list ref,
from which it is easy to break type safety.
So, your example shows that it would be unsafe to say that a "let
module M = A in B" expression is nonexpansive if B is nonexpansive.
One would need to inspect the module expression A to establish that it
is nonexpansive. This is what we do for ordinary "let" expressions:
"let x = A in B" is nonexpansive if both A and B are nonexpansive.
There are two concerns here. The practical one is that the module
language is quite complex and I really don't feel like implementing a
syntactic nonexpansiveness check for module expressions.
The conceptual concern is that the type system for the module language
is somewhat richer than that of the core language -- it has "deep"
polymorphism, subtyping and some forms of dependent types -- so it is
not entirely clear to me that the value restriction and the syntactic
nonexpansiveness criterion that work for the core language would also
work for the module language.
- Xavier Leroy
next prev parent reply other threads:[~2004-12-08 16:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-06 19:55 Jim Farrand
2004-12-07 7:12 ` [Caml-list] " Alain Frisch
2004-12-07 13:43 ` Damien Doligez
2004-12-07 14:57 ` Andreas Rossberg
2004-12-07 17:44 ` Damien Doligez
2004-12-07 18:08 ` Alain Frisch
2004-12-07 21:04 ` Damien Doligez
2004-12-07 21:43 ` Alain Frisch
2004-12-08 3:30 ` nakata keiko
[not found] ` <8002B033-4906-11D9-8195-000D9345235C@inria.fr>
2004-12-09 0:56 ` nakata keiko
2004-12-09 1:27 ` Jacques Garrigue
2004-12-08 10:53 ` Damien Doligez
2004-12-08 12:39 ` Alain Frisch
2004-12-08 14:23 ` Jacques Garrigue
2004-12-09 3:07 ` skaller
2004-12-09 4:53 ` Jacques Garrigue
2004-12-08 16:10 ` Xavier Leroy [this message]
2004-12-07 18:13 ` William Lovas
2004-12-08 0:27 ` Jacques Garrigue
2004-12-07 18:41 ` Boris Yakobowski
2004-12-07 19:38 ` Jim Farrand
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=20041208161056.GA703@yquem.inria.fr \
--to=xavier.leroy@inria.fr \
--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).