From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: sacerdot@students.cs.unibo.it
Cc: caml-list@inria.fr
Subject: Re: Strange type error
Date: Tue, 24 Oct 2000 16:35:15 +0900 [thread overview]
Message-ID: <20001024163515X.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: Your message of "Mon, 23 Oct 2000 17:35:55 +0200" <20001023173554.A30886@students.cs.unibo.it>
From: Claudio Sacerdoti Coen <sacerdot@students.cs.unibo.it>
> let a.mli be
>
> type 'a section_path = { x : int; }
> and mind_section_path = [ `MIND] section_path
> type const_section_path = [ `CONST] section_path
>
> and b.mli be
>
> type 'a section_path = { x : int; }
> type mind_section_path = [ `MIND] section_path
> type const_section_path = [ `CONST] section_path
>
> b.mli is compiled without problems, but for a.mli I get
>
> File "prova.mli", line 3, characters 26-35:
> This type [ `CONST] should be an instance of type [ `MIND]
>
> that seems nonsense to me. Someone could explain the error?
For a long time, the answer was: "this is not a bug, this is a
feature." (cf. this mailing list more than 1 year ago)
That is, in recursive type definitions, as in recursive value
definitions, the polymorphism is only given after a definition block
is finished. As a result, the definition in a.mli actually means:
type 'a section_path = { x : int } constraint 'a = [ `MIND]
You can see it by doing `ocamlc -i -c a.mli'.
In the current version (upcoming 3.01), this problem is solved:
type definitions are assumed to be polymorphic, and if you want the
above behavior you must explicitly request it. As a result a.mli and
b.mli become equivalent. So we can now assume that this was a bug.
Cheers,
Jacques Garrigue
---------------------------------------------------------------------------
Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp
<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
next prev parent reply other threads:[~2000-10-24 15:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-23 15:35 Claudio Sacerdoti Coen
2000-10-24 7:05 ` Judicael Courant
2000-10-24 7:35 ` Jacques Garrigue [this message]
2000-10-24 16:47 Brent Fulgham
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=20001024163515X.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=sacerdot@students.cs.unibo.it \
/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).