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 90C96BC69 for ; Tue, 1 May 2007 18:14:33 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l41GEXHc025511 for ; Tue, 1 May 2007 18:14:33 +0200 Received: by ug-out-1314.google.com with SMTP id k3so65374ugf for ; Tue, 01 May 2007 09:14:31 -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=oOBP9AAjvxHTXU5uj8pmOP4Z46WWzDNkrbEPSmP6bicd3Pdf3+J+SbPI495RsbhX2OjDURZfrUJj3cGC3dZ0GyRgA4gA1onCLQV/1jee4o2qXR1p+1Q+93r0yDUMN2I8txnpcjTBK+K0nniI2N5i32HjpCnDe3gCXVPzPjo3KFI= 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=JZQtERWLLezbnI3PTCey22zEwG/kCBAMWtcJoSY1b6R+YlDx63Tdc/qe4l8teIMrlWJ1yA6X76IA9Xy5j1LK0AcuN3399GnHVzdALd40VNivs/bK95t+u7rguxHfxVFVPn8nc/6nBUb1qB9vhL1ar/Y2TzyP8tkczKyFZzmvmHo= Received: by 10.67.102.16 with SMTP id e16mr429263ugm.1178036070416; Tue, 01 May 2007 09:14:30 -0700 (PDT) Received: from ?192.168.1.34? ( [83.52.237.136]) by mx.google.com with ESMTP id k1sm1072468ugf.2007.05.01.09.14.27; Tue, 01 May 2007 09:14:28 -0700 (PDT) In-Reply-To: References: <220DCCF0-FD2D-4116-8E30-992C1AD3FE95@gmail.com> <08610813-0F6F-4BC4-BB22-42FB0CF5EC84@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 17:14:26 +0100 To: Nicolas Pouillard X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 46376769.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 46376769.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 variants:01 constructors:01 constr:01 camlp:01 sexp:01 variants:01 expr:01 sexp:01 bindings:01 vars:01 bindings:01 expr:01 vars:01 ctyp:01 RfTag is gone, apparently. How do you process variants then? The only reference to constructors I could find is with_constr in Camlp4Ast.partial.ml. It's applicable to modules, apparently. The original code is attached below. Thanks, Joel --- and sexp_of_variants_loop _loc acc = function | RfTag (cnstr, _, []) -> ( <:patt< `$cnstr$ >>, None, <:expr< Sexplib.Sexp.Atom $str:cnstr$ >> ) :: acc | RfTag (cnstr, _, tps) -> let fps = List.map (sexp_of_type _loc) tps in let bindings, patts, vars = Gen.mk_bindings _loc fps in let arg_patt = tuplify_patts _loc patts in let cnstr_expr = <:expr< Sexplib.Sexp.Atom $str:cnstr$ >> in ( <:patt< `$cnstr$ $arg_patt$ >>, None, <:expr< let $list:bindings$ in Sexplib.Sexp.List $Gen.mk_expr_lst _loc (cnstr_expr :: vars)$ >> ) :: acc | RfInh (TyVrn (_loc, row_fields, _)) -> List.fold_left (sexp_of_variants_loop _loc) acc row_fields | RfInh tp -> let tp_path, call = match tp with | <:ctyp< $tp1$ $tp2$ >> -> let fp1 = sexp_of_type _loc tp1 in let fp2 = sexp_of_type _loc tp2 in let tp_path = List.rev (Gen.tp_path (get_appl_path _loc tp1)) in let expr = sexp_of_appl_fun _loc fp1 fp2 in tp_path, expr | _ -> let tp_path = Gen.tp_path tp in match tp_path with | tn :: path -> tp_path, mk_abst_call _loc tn path | [] -> assert false (* impossible *) in ( <:patt< (#$tp_path$ as v) >>, None, <:expr< $call$ v >> ) :: acc and sexp_of_variant _loc row_fields = `Match ( List.rev (List.fold_left (sexp_of_variants_loop _loc) [] row_fields)) -- http://wagerlabs.com/