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.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 336A8BC69 for ; Tue, 1 May 2007 15:21:49 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l41DLmPf025091 for ; Tue, 1 May 2007 15:21:48 +0200 Received: by ug-out-1314.google.com with SMTP id k3so42252ugf for ; Tue, 01 May 2007 06:21:48 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=fwKa5XyMwZNIc3q64+cfPAP3FEO5L9yKhNNfaqCCw2EgzQ2ZMLZpCnt+w3G4AlITpn7ukgLdymQSaejRtnvWLqv0AqgrGhVdP6zAOcVIDhl6wASzJMcR6dAnL/SD639w8gsQsRkYqt0jXnZyWXUyEEzlvyuSnwPx0Ke5C1o/z5s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=o1Me+6LJg5eGVGz+p+GdfzW9vxE37joB/IunHKI0H6hXUZq7wvx4L/5ja2emG+cAlrHElMZ7i37jia+FnyScNEOEjwkQz1s2GTBuYfuLCUsB5TqGRzlwmX53Ra9oNpJYFjitGmWiz8cAA3OS1Xros165ZrgRO50HwdtlOth5hEs= Received: by 10.66.240.12 with SMTP id n12mr316135ugh.1178025708395; Tue, 01 May 2007 06:21:48 -0700 (PDT) Received: from ?192.168.1.34? ( [83.52.237.136]) by mx.google.com with ESMTP id 54sm804075ugp.2007.05.01.06.21.46; Tue, 01 May 2007 06:21:47 -0700 (PDT) In-Reply-To: References: <220DCCF0-FD2D-4116-8E30-992C1AD3FE95@gmail.com> <72EB1952-F2C8-44AC-B1A6-7D8CE5F4A157@gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: "Caml List" Content-Transfer-Encoding: 7bit From: Joel Reymont Subject: Re: Upgrading sexplib-2.7.0 to camlp4 3.10 Date: Tue, 1 May 2007 14:21:45 +0100 To: Nicolas Pouillard X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 46373EEC.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 46373EEC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 ctyp:01 ctyp:01 sexp:01 camlp:01 syntax:01 syntax:01 expr:01 bindings:01 bindings:01 expr:01 sexp:01 vars:01 vars:01 denoting:01 Nicolas, Thank you for your patience! As per your suggestion, I converted this | <:ctyp< ( $list:tys$ ) >> -> tupl _loc (List.map aux tys) into this | <:ctyp< ( $tup:tys$ ) >> -> tupl _loc (List.map aux (list_of_ctyp tys [])) where tupl is actually sexp_of_tuple below. The ultimate goal is to convert ( t1 * ... * tN ) into a Lisp-style (t1, ..., tN). My next issue is an error in sex_of_tuple: This expression has type (Camlp4.PreCast.Syntax.Ast.patt * Camlp4.PreCast.Syntax.Ast.expr) list but is here used with type Camlp4.PreCast.Syntax.Ast.binding list This points at $list:bindings$. I attached mk_bindings at the end, in case it's of any use. How should I rewrite $list:bindings$ here? I don't understand why $list:bindings$ is assumed to be of type binding list when bindings itself is [(patt, expr)]. Thanks, Joel --- (* Conversion of tuples *) let sexp_of_tuple _loc fps = let bindings, patts, vars = Gen.mk_bindings _loc fps in let expr = <:expr< let $list:bindings$ in Sexplib.Sexp.List $Gen.mk_expr_lst _loc vars$ >> in let matching = ( <:patt< ( $list:patts$ ) >>, None, expr ) in `Match [matching] (* [mk_rev_bindings _loc fps] takes a list of values of the form [`Fun fun_expr] and [`Match matching]. [fun_expr] is an expression denoting a function, and [matching] is a list of bindings. @return the tuple [(bindings, patts, var_exprs)], where [bindings] is a list of [(pattern, expression)] tuples, [patts] is the list of those patterns, and [var_exprs] is the expression (variable) associated with each of those patterns. The resulting lists are reversed. *) let mk_rev_bindings _loc fps = let coll (i, bindings, patts, vars) fp = let name = "v" ^ string_of_int i in let var_expr = ide _loc name in let expr = match fp with | `Fun fun_expr -> <:expr< $fun_expr$ $var_expr$ >> | `Match matchings -> <:expr< match $var_expr$ with [ $list:matchings$ ] >> in let patt = idp _loc name in i - 1, (patt, expr) :: bindings, patt :: patts, var_expr :: vars in let n = List.length fps in let _, bindings, patts, vars = List.fold_left coll (n, [], [], []) fps in bindings, patts, vars (* [mk_bindings _loc fps] same as [mk_rev_bindings] but the resulting lists are in order. *) let mk_bindings _loc fps = mk_rev_bindings _loc (List.rev fps) -- http://wagerlabs.com/