From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id D0866BC57 for ; Wed, 15 Dec 2010 09:31:38 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnwEABoLCE2BWB4FhWdsb2JhbACkOgELCwoFEyTBOYVKBIp7gxY X-IronPort-AV: E=Sophos;i="4.59,347,1288566000"; d="scan'208";a="70691489" Received: from mx1.imag.fr (HELO shiva.imag.fr) ([129.88.30.5]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Dec 2010 09:31:38 +0100 Received: from rhin.imag.fr (rhin.imag.fr [147.171.129.2]) by shiva.imag.fr (8.13.8/8.13.8) with ESMTP id oBF8VVZV013900 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 15 Dec 2010 09:31:31 +0100 Received: from [10.0.2.15] (tima-dhcp-h44.imag.fr [147.171.132.68]) by rhin.imag.fr (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oBF8VTbF014717; Wed, 15 Dec 2010 09:31:31 +0100 Message-ID: <4D087CDF.7000004@imag.fr> Date: Wed, 15 Dec 2010 09:31:27 +0100 From: Florent Ouchet Reply-To: florent.ouchet@imag.fr Organization: Tima/CIS User-Agent: Thunderbird 2.0.0.24 (X11/20100228) MIME-Version: 1.0 To: Alexander Bernauer Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] type of high order functions References: <20101214203043.GA9093@apus.ethz.ch> In-Reply-To: <20101214203043.GA9093@apus.ethz.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (shiva.imag.fr [129.88.30.5]); Wed, 15 Dec 2010 09:31:31 +0100 (CET) X-IMAG-MailScanner-Information: Please contact MI2S MIM for more information X-MailScanner-ID: oBF8VVZV013900 X-IMAG-MailScanner: Found to be clean X-IMAG-MailScanner-SpamCheck: X-IMAG-MailScanner-From: florent.ouchet@imag.fr MailScanner-NULL-Check: 1293006695.77685@C2pJBsGrnnnSTeS0Hy+Lxw X-Spam: no; 0.00; inference:01 inference:01 tima:01 compile:01 caml-list:01 functions:01 constraint:01 constraint:01 int:01 int:01 algorithm:01 algorithm:01 imag:02 string:02 string:02 Alexander Bernauer a écrit : > Why is it that the first example does not compile while the later ones do? > Because type constraints are considered: - only for type restriction, not for generalization; - after the type inference algorithm is executed. In your first case, the type inference algorithm gave "f : (int -> string) -> int -> string)" after it considered "x" but before it starts considering "y" (that step will then fail) and a long time before it considers your explicit type constraint. In your second case, you splitted the statements in 2 blocks, the type inference algorithm is called twice (once per block), and this time your type constraint was considered before x and y are effectively typed. -- Florent Ouchet PhD Student CIS/VDS Team - TIMA Laboratory