From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: "Milan Stanojević" <milanst@gmail.com>
Cc: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] First Class modules -A bug in 4.00?
Date: Sun, 10 Jun 2012 18:27:44 +0900 [thread overview]
Message-ID: <51DC4853-76E9-4461-A339-659999595504@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <CAKR7PS-4RpG61ZNH7HA7pJGCtgjaAj0hRNpWjwfq4O+YSPb92Q@mail.gmail.com>
On 2012/06/09, at 5:25, Milan Stanojević wrote:
> On Thu, Jun 7, 2012 at 11:22 PM, Jacques Garrigue
> <garrigue@math.nagoya-u.ac.jp> wrote:
>> On 2012/06/08, at 11:35, Hongbo Zhang wrote:
>>
>>> Hi, List
>>> I am not sure this is a bug or not?
>>>
>>> Below is a contrived example:
>>> ------------------
>>> module type S = sig
>>> type t=int
>>> module X : sig type u end
>>> end
>>>
>>> let f ( module X : S) (y:X.X.u) =
>>> 3
>>> --------------------
>>> Error: This pattern matches values of type X.X.u
>>> but a pattern was expected which matches values of type X.X.u
>>> The type constructor X.X.u would escape its scope
>>> -- Thanks
>>
>> Definitely, this is not a bug.
>> Type X.X.u is abstract, and showing it outside (as by taking an argument
>> of that type) would be meaningless.
>
> What do you mean by "abstract type" here?
The problem here is that X.X.u is both abstract, and introduced by the
pattern (module X : S), and as such is only valid in the scope of X.
> For example, I'd call X.t in the following example abstract and it is
> perfectly fine to use it as argument.
> module X : sig type t end = struct type t = int end
> let f (x : X.t) = 3
You can actually get the same error by using a reference:
let r = ref [];;
module X : sig type t end = struct type t = int end
let f (x : X.t) = 3 ;;
r := [f];;
Error: This expression has type X.t -> int
but an expression was expected of type X.t -> int
The type constructor X.t would escape its scope
In case of a usual module definition, references defined before it
are out of scope.
Jacques Garrigue
prev parent reply other threads:[~2012-06-10 9:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 2:35 Hongbo Zhang
2012-06-08 3:22 ` Jacques Garrigue
2012-06-08 15:25 ` bob zhang
2012-06-08 15:29 ` bob zhang
2012-06-08 20:25 ` Milan Stanojević
2012-06-10 9:27 ` Jacques Garrigue [this message]
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=51DC4853-76E9-4461-A339-659999595504@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=milanst@gmail.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).