From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id CCA9FBCAE for ; Thu, 30 Jun 2005 20:31:25 +0200 (CEST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5UIVPRW014900 for ; Thu, 30 Jun 2005 20:31:25 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id j5UIU1Xs023543 ; Thu, 30 Jun 2005 20:30:01 +0200 (CEST) X-Ids: 166 Received: from hydrogene.pps.jussieu.fr (localhost.localdomain [127.0.0.1]) by hydrogene.pps.jussieu.fr (8.13.4/jtpda-5.4) with ESMTP id j5UIU08M026818 ; Thu, 30 Jun 2005 20:30:00 +0200 Received: from localhost (verlague@localhost) by hydrogene.pps.jussieu.fr (8.13.4/8.13.2/Submit) with ESMTP id j5UIU08j026815; Thu, 30 Jun 2005 20:30:00 +0200 Date: Thu, 30 Jun 2005 20:30:00 +0200 (CEST) From: Julien Verlaguet To: Andreas Rossberg Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] bizarre type In-Reply-To: <42C4228D.3080000@ps.uni-sb.de> Message-ID: References: <42C4228D.3080000@ps.uni-sb.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.7.2 (shiva.jussieu.fr [134.157.0.166]); Thu, 30 Jun 2005 20:30:05 +0200 (CEST) X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Miltered: at concorde with ID 42C43A7D.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 42C43A29.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 annotation:01 compiler:01 infers:01 val:01 compiler:01 ...:98 abstract:01 pps:01 jussieu:01 int:01 int:01 types:02 string:03 string:03 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=1.1 required=5.0 tests=ITS_LEGAL autolearn=disabled version=3.0.2 X-Spam-Level: * > for any x and y, your type annotation does not induce anything about the > instantiation of g's variable 'a. The following is perfectly legal: > > g ("hello" : int t) true > > The compiler just infers the most general type. two things : first # type 'a t=string;; type 'a t = string # let g (x : 'a) (y : 'a t)=();; val g : 'a -> 'a t -> unit = # g 3;; - : int t -> unit = here we should have int t=string='_a t ... second : I strongly disaggree with the fact that the compiler infered the most general type in this case. Because I specified it. when you write (let f=fun (x : 'a) (y : 'a) -> (x,y)), you force the type of x and y to be equal. It would be a problem if one could write (f true 3). J PS : The behavior with abstract types is the one expected and my example in the previous mail was irrelevant (sorry about that).