From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA07439 for caml-redistribution; Wed, 19 Nov 1997 10:40:07 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA07393; Wed, 19 Nov 1997 10:39:33 +0100 (MET) From: Pierre Weis Message-Id: <199711190939.KAA07393@pauillac.inria.fr> Subject: Re: Type-checking bug (or feature?) in O'Caml 1.06 In-Reply-To: from Paul Stodghill at "Nov 18, 97 02:05:56 pm" To: stodghil@cs.cornell.edu (Paul Stodghill) Date: Wed, 19 Nov 1997 10:39:33 +0100 (MET) Cc: caml-list@pauillac.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > 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 names 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/