From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA06655; Wed, 11 Aug 2004 12:09:36 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA06057 for ; Wed, 11 Aug 2004 12:09:35 +0200 (MET DST) From: fis@wiwi.hu-berlin.de Received: from miro.wiwi.hu-berlin.de (miro.wiwi.hu-berlin.de [141.20.103.80]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7BA9YmL030097 for ; Wed, 11 Aug 2004 12:09:34 +0200 Received: from mini (miro [141.20.103.80]) by miro.wiwi.hu-berlin.de (8.11.7+Sun/8.8.6) with ESMTP id i7BA9Xq10769 for ; Wed, 11 Aug 2004 12:09:33 +0200 (MET DST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16665.61343.130286.600455@gargle.gargle.HOWL> Date: Wed, 11 Aug 2004 12:06:23 +0200 To: caml-list@inria.fr Subject: [Caml-list] strange effect of type annotation X-Miltered: at nez-perce with ID 4119F05E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; stumbling:01 bug:01 instructive:01 0.,:01 0.,:01 checker:01 matthias:01 ocaml:01 ocaml:01 int:01 int:01 float:02 float:02 typing:03 slightly:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk hi all, I was just stumbling over something that is surely not a bug but a slightly counterintuitive effect in the ocaml type system and thought somebody might have an instructive comment. (I know I should go read the papers on ocaml typing, though. :-) > let good : (int * float) = let x = fst in (x (0,1), x (0., 1.));; > let bad : (int * float) = let x: ('a * 'a) -> 'a = fst in (x (0,1), x (0., 1.));; The type checker sais: > let bad : (int * float) = let x: ('a * 'a) -> 'a = fst in (x (0,1), x (0., 1.));; > ^^^^^^^^ > This expression has type float * float but is here used with type int * int I know that the type of fst is more general than this, but it looks like it would have done the job for me here. Why doesn't it? And is there a type annotation for x that does? cheers, matthias ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners