From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr 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 16665BC0A for ; Wed, 4 Apr 2007 17:17:25 +0200 (CEST) Received: from [128.93.11.101] (buzet.inria.fr [128.93.11.101]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l34FHL8E024269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 4 Apr 2007 17:17:22 +0200 Message-ID: <4613C0AA.8010405@inria.fr> Date: Wed, 04 Apr 2007 17:13:46 +0200 From: Alain Frisch User-Agent: Thunderbird 1.5.0.7 (X11/20060927) MIME-Version: 1.0 To: Roland Zumkeller Cc: Loup Vaillant , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Polymorphic recursion References: <6f9f8f4a0704030959l8ebb155g8532e3ee6d31c66d@mail.gmail.com> In-Reply-To: X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4613C181.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; frisch:01 frisch:01 recursion:01 recursive:01 ocaml:01 -rectypes:01 typecheck:01 val:01 seq:01 seq:01 -rectypes:01 polymorphic:01 wrote:01 wrote:01 caml-list:01 Roland Zumkeller wrote: > On 03/04/07, Loup Vaillant wrote: >> Can't we implement non uniform recursive function (efficiently, or at >> all)?. > > It has actually been done: call ocaml with the option "-rectypes" and > your example will work as is. No. The example would typecheck and the following type will be inferred: val size : ('a * 'a as 'a) seq -> int = but since there is no value of type ('a * 'a as 'a) (for some 'a), you will be able to apply the function only to the value Unit: # size Unit;; - : int = 0 # size (Seq (1, Unit));; This expression has type int * 'a seq but is here used with type ('b * 'b as 'b) * ('b * 'b) seq This is a good illustration of why -rectypes is not enabled by default. -- Alain