From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9B7B4BC8E for ; Tue, 15 Feb 2005 22:29:13 +0100 (CET) Received: from nutty.inf.ed.ac.uk (nutty.inf.ed.ac.uk [129.215.216.3]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1FLSrju007593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Feb 2005 22:29:13 +0100 Received: from [129.215.96.135] (dhcp-96-135.dcs.ed.ac.uk [129.215.96.135]) by nutty.inf.ed.ac.uk (8.12.8/8.12.8) with ESMTP id j1FLSqpH027594 for ; Tue, 15 Feb 2005 21:28:52 GMT Mime-Version: 1.0 (Apple Message framework v619.2) Content-Transfer-Encoding: quoted-printable Message-Id: <7bf1f3b95c18eeda0ed169eb7f73d6f0@urbanet.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed To: caml-list@yquem.inria.fr From: Gilles Dubochet Subject: Polymorphic variant typing Date: Tue, 15 Feb 2005 21:28:52 +0000 X-Mailer: Apple Mail (2.619.2) X-Miltered: at concorde with ID 42126995.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; o'caml:01 wand:01 notation:01 notation:01 o'caml:01 int':01 intuitively:01 cheers:01 polymorphic:01 expression:01 typing:01 int:01 int:01 argument:01 match:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Hello everyone, The following O'Caml expression: let incr g x =3D match x with | `Int i -> `Int (i+1) | x -> (g x);; Receives type: (([> `Int of int ] as 'a) -> ([> `Int of int ] as 'b)) -> 'a -> 'b Why? I am quite astonished. I would have expected a type more like: ([> ] -> [> ]) -> [> `Int of int ] -> [> `Int of int ] or in Wand or R=E9my-like row variable notation with which I am a little=20= more comfortable (I am not exactly sure the preceding type is correct=20 in the 'at leat - at most' notation of O'Caml): ([ 'a ] -> [ 'b ]) -> [ `Int of int | 'a ] -> [ `Int of int | 'b ] Could anyone be kind enough to give me some clues about where to look=20 at to find an explanation or even better, explain me what is going on?=20= I am particularly puzzled by the fact that the g function's *argument*=20= type is 'at least `Int of int'. This rejects the following code which=20 seems intuitively correct: incr (function `Float f -> `Float (f+.1.));; Thank you. Cheers, Gilles.=