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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DED72BC6B for ; Tue, 22 Jan 2008 14:43:11 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.25,233,1199660400"; d="scan'208";a="8162403" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail3-relais-sop.national.inria.fr with SMTP; 22 Jan 2008 14:43:11 +0100 Received: by ausone.inria.fr (sSMTP sendmail emulation); Tue, _d Jan 2008 14:42:10 +0100 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] camlp4 To: christian.sternagel References: <1200676132.4790dd24bfca9@web-mail2.uibk.ac.at> <95513600801181130u2f6584b8w505cd10e848bcc65@mail.gmail.com> <1200685853-sup-3987@ausone.local> <1200755341.4792128d5dad6@web-mail2.uibk.ac.at> <1200842484-sup-3237@ausone.local> <20080122133355.GI3862@pc6197-c703.uibk.ac.at> In-Reply-To: <20080122133355.GI3862@pc6197-c703.uibk.ac.at> Date: Tue, 22 Jan 2008 14:42:00 +0100 Message-Id: <1201009268-sup-196@port-ext18.ensta.fr> User-Agent: Sup/git Content-Type: multipart/signed; protocol=""application/pgp-signature""; boundary="=-1201009330-965264-77665-2643-4-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Spam: no; 0.00; camlp:01 wadler:01 expr:01 expr:01 camlp:01 syntax:01 syntax:01 abstract:01 rec:01 rec:01 caml-list:01 cleanly:01 patt:01 patt:01 grammar:02 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1201009330-965264-77665-2643-4-= Content-Type: text/plain; charset=UTF-8 Excerpts from christian.sternagel's message of Tue Jan 22 14:33:55 +0100 2008: > > > How about the transformation from Chapter 7 of [1] (by Philip Wadler)? > > > It should be similar to the `pseudo code': > > > > > > type expr = ...;; > > > type patt = ...;; > > > type qualifier = Gen of patt * expr | Filt of expr;; > > > type compr = (expr * qualifier list);; > > > let rec expr = function > > > | ... > > > | (e, qs) -> transform [] (e, qs) > > > | ... > > > and transform l = function > > > | (e, []) -> expr e :: expr l > > > | (e, Filt f :: qs) -> if expr f then transform l (e, qs) else expr l > > > | (e, Gen (p, l1) :: qs) -> > > > let rec h = function > > > | [] -> expr l > > > | u :: us -> (function p -> transform (h us) (e, qs) | _ -> h us) u > > > in h (expr l1) > > > ;; > > > > > > (* where h, u, us are fresh variables not occurring in e, l1, l, or qs *) > > > > > > Sorry I'm not yet familiar with camlp4 grammar extensions, but of course > > > above code would make use of them otherwise. > > > > Yes this approach can be integrated with a camlp4 extension. > > > > > It is stated in [1] that the resulting code is optimal in that it > > > performs the minimum number of cons operations. > > > > Nice. > > > > > And I did ignore the hint that fresh variables make things > > > complicated :). > > > > Yes it can... > > > > Best regards, > > > > -- > > Nicolas Pouillard aka Ertai > > > I deduce that there is no standard way of introducing > `fresh' (w.r.t. the abstract syntax tree) variables > within a camlp4 syntax extension? Wouldn't that be nice? =) > That would be nice, but doing it cleanly would require a large amount of work and user visible changes. -- Nicolas Pouillard aka Ertai --=-1201009330-965264-77665-2643-4-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin) iD8DBQFHlfKyj+FCNw9dwLkRAsM6AJ0c+A6R77Ty0eknXtawtIdopsMm6gCfc2x6 Ff7aMvAs0gKMGc49QTHRHO0= =rpgB -----END PGP SIGNATURE----- gpg: Invalid passphrase; please try again ... --=-1201009330-965264-77665-2643-4-=--