caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Louis Gesbert <louis.gesbert@mlstate.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Implicitely abstracted type
Date: Thu, 16 Dec 2010 16:15:48 +0100	[thread overview]
Message-ID: <4D0A2D24.8090401@frisch.fr> (raw)
In-Reply-To: <4D0A14BE.9080305@mlstate.com>

On 12/16/2010 02:31 PM, Louis Gesbert wrote:
> What happens is that a sum-type defined in a module can implicitely be
> turned into abstract because of its inner contents.

Here is an explanation of this behavior. When applying a functor of type 
functor(X:S1) -> S2 to a module of type T, the module type for the 
result can be obtained in two different ways:

(1) T is a path: the module type is obtained by substituting X with T in S2.

(2) T is not a path: the module type is obtained by computing the 
smallest supertype of S2 that doesn't contain X anymore (under the extra 
assumption that X has type T).


In your example, you are in case (2), and the only way (of which the 
compiler is aware) to get rid of the dependency on the functor's formal 
argument is to turn a concrete type declaration into an abstract one. If 
you are interested in the implementation, this happens in the function 
Ctype.nondep_type_decl (where a Not_found exception raised by 
nondep_type_rec is turned into a Type_abstract).

Admittedly, this fallback behavior of turning automatically a concrete 
type declaration into an abstract one is not completely natural. As far 
as I can tell, it would be straightforward to add a warning in this 
situation.  Do you want to fill a feature request?


Alain


  parent reply	other threads:[~2010-12-16 15:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-16 13:31 Louis Gesbert
2010-12-16 14:23 ` [Caml-list] " rossberg
2010-12-16 15:15 ` Alain Frisch [this message]
2010-12-16 16:03   ` rossberg

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=4D0A2D24.8090401@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=louis.gesbert@mlstate.com \
    /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).