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_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 491D6BC69 for ; Thu, 3 May 2007 07:59:00 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.238]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l435wxsV026969 for ; Thu, 3 May 2007 07:58:59 +0200 Received: by nz-out-0506.google.com with SMTP id l8so614571nzf for ; Wed, 02 May 2007 22:58:59 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uJNbOI9OZxgTdK5aX8zz4wjRpMrujd8cRqA9M+XP8gBlrhLtd7v7WR1wkpHmYTgf22+1mV72TFmyQcuLAa5uUcRuJ5FbzIQO0lP0mOm4UGAIv8eFYGWlFNufCqQ7WCqHBPOn3+uJq9mqnTUSRsvAiHrCl3fqz0wPyYK/zxpcXXQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SM6Xr6vOfobEvyrDkfZ2XTnPLHi2nTQUAed3DaaEhajrp85fuLMHWibaAYvWRq5oB66FvWbmuAXZA3dX/27xSmYJFTMH07yDcOe0/GamC9+oo322Ujr7qwuO1HS2WsIaOlvh1HzWiFzvf0kB/bhJ26IunEHWKlZQbdIT1aeyIk4= Received: by 10.115.61.1 with SMTP id o1mr528001wak.1178171938881; Wed, 02 May 2007 22:58:58 -0700 (PDT) Received: by 10.114.124.17 with HTTP; Wed, 2 May 2007 22:58:58 -0700 (PDT) Message-ID: <90823c940705022258h26c7dc34t448013ac7127c644@mail.gmail.com> Date: Thu, 3 May 2007 09:58:58 +0400 From: "Dmitry Bely" To: "Caml List" Subject: Re: [Caml-list] camlp4 3.10: Matching variant types In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <220DCCF0-FD2D-4116-8E30-992C1AD3FE95@gmail.com> <08610813-0F6F-4BC4-BB22-42FB0CF5EC84@gmail.com> X-j-chkmail-Score: MSGID : 46397A23.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46397A23.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 ioxml:01 syntax:01 camlp:01 expr:01 ppf:01 tpl:01 ctyp:01 ioxml:01 ctyp:01 sil:98 pel:98 pel:98 rec:01 caml-list:01 Probably the following is related to Joel's questions on variant type matching. I am trying to convert IoXML syntax extension to the new camlp4. Currently I am stuck here: ... value gen_output_cons (loc, c, tl) = let p = let p = <:patt< $uid:c$ >> in let (p, _) = List.fold_left (fun (p, cnt) _ -> let p = <:patt< $p$ $lid:pname cnt$ >> in (p, cnt + 1)) (p, 1) tl in p in let e = gen_xprint_cons loc c tl in (p, None, e) ; ... value gen_output_sum loc cdl = let mc = List.fold_right (fun cd mc -> let (p, _, e) = gen_output_cons cd in <:match_case< $p$ -> $e$ | $mc$ >>) cdl <:match_case<>> in <:expr< fun ppf -> fun [ $mc$ ] >> ; ... value gen_output_funs loc tdl sil = let pel = List.fold_right (fun ((loc, n), tpl, tk, cl) pel -> let body = loop tk where rec loop = fun [ <:ctyp< [ $cdl$ ] >> -> gen_output_sum loc cdl File "pa_ioXML.ml", line 257, characters 58-61: This expression has type Camlp4.PreCast.Ast.ctyp but is here used with type (Camlp4.PreCast.Ast.Loc.t * string * Camlp4.PreCast.Ast.ctyp list) list As usual: (cdl) was a list before, now it is not. Is were a simple way to get a list and make (gen_output_sum) happy? Or this should be complete rewritten - how? - Dmitry Bely