From: Pierre Weis <weis@pauillac.inria.fr>
To: stodghil@cs.cornell.edu (Paul Stodghill)
Cc: caml-list@pauillac.inria.fr
Subject: Re: Type-checking bug (or feature?) in O'Caml 1.06
Date: Wed, 19 Nov 1997 10:39:33 +0100 (MET) [thread overview]
Message-ID: <199711190939.KAA07393@pauillac.inria.fr> (raw)
In-Reply-To: <mlzpn2rpij.fsf@mario.cs.cornell.edu> from Paul Stodghill at "Nov 18, 97 02:05:56 pm"
> The new behavior is even more bizarre than I had first thought.
>
> ---------------------------------------------------------------------------
> % cat foo.mli
> type ('a, 'b) t;;
> val iter: ('a -> 'b -> 'unit) -> ('a, 'b) t -> unit
[...]
> % ocamlc -v -i -c foo.mli
> [...]
> val iter : ('a -> 'b -> 'c) -> ('a, 'b) t -> unit
>
> Why is the generated type different than the declared type?
It is not, since you declared iter with the same type scheme:
> val iter: ('a -> 'b -> 'unit) -> ('a, 'b) t -> unit
^
the ' symbole turns out 'unit to be a type variable. Free variables
<I>names</I> in type schemes are irrelevant (as for functions
abstracted arguments in programs). Thus, in its messages, the compiler
generates new names for type variables as 'a, 'b, 'c, ..., and
the original names written in the source programs are forgotten.
For instance:
# type ('key, 'assoc_val) t = ('key * 'assoc_val) list;;
type ('a, 'b) t = ('a * 'b) list
Thus, the declared type scheme and the generated type scheme are equivalent.
Best regards,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
next prev parent reply other threads:[~1997-11-19 9:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-11-18 18:57 Paul Stodghill
1997-11-18 19:05 ` Paul Stodghill
1997-11-19 9:39 ` Pierre Weis [this message]
1997-11-19 9:24 ` Pierre Weis
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=199711190939.KAA07393@pauillac.inria.fr \
--to=weis@pauillac.inria.fr \
--cc=caml-list@pauillac.inria.fr \
--cc=stodghil@cs.cornell.edu \
/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