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=1.1 required=5.0 tests=AWL,SPF_SOFTFAIL 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 76411BC0A for ; Tue, 3 Apr 2007 22:00:41 +0200 (CEST) Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net [69.17.117.5]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l33K0duD011115 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 3 Apr 2007 22:00:40 +0200 Received: (qmail 5439 invoked from network); 3 Apr 2007 20:00:37 -0000 Received: from shell4.sea5.speakeasy.net ([69.17.116.5]) (envelope-sender ) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 3 Apr 2007 20:00:37 -0000 Date: Tue, 3 Apr 2007 13:00:37 -0700 (PDT) From: brogoff To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Polymorphic recursion In-Reply-To: <9d3ec8300704031035g5a69d98dx7f7e8e5b2f7037f3@mail.gmail.com> Message-ID: References: <6f9f8f4a0704030959l8ebb155g8532e3ee6d31c66d@mail.gmail.com> <9d3ec8300704031035g5a69d98dx7f7e8e5b2f7037f3@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 4612B267.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursion:01 recursion:01 recursive:01 seq:01 seq:01 recursive:01 polymorphism:01 2007,:98 polymorphic:01 polymorphic:01 wrote:01 rec:01 rec:01 caml-list:01 speakeasy:01 On Tue, 3 Apr 2007, Till Varoquaux wrote: > Therefor, if you wish to use polymorphic recursion (yep you can) you > might want to use something where you have to specify the type; this > includes records, objects and recursive modules. So this > > type 'a seq = Unit | Seq of ('a * ('a * 'a)seq) > > type szRec={f:'a.'a seq -> int};; > > let size= > let rec s = > {f=function > | Unit -> 0 > | Seq(_, b) -> 1 + 2 * s.f b} > in > s.f > > might be what you where yearning for. What I'd be yearning for would be more like let rec size : 'a . 'a seq -> int = fun s -> match s with Unit -> 0 | Seq(_,b) -> 1 + 2 * (size b) rather than having to use recursive modules or higher rank polymorphism of record fields/polymorphic methods. -- Brian