caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] AST transformation and scrapping boilerplate code
Date: Mon, 30 Apr 2007 09:53:14 +0100	[thread overview]
Message-ID: <A2FB71CF-6F3F-4DBB-B4ED-42DF51C27D5C@gmail.com> (raw)
In-Reply-To: <cd67f63a0704300121i46af58dcxe458867b09c34af3@mail.gmail.com>

A combination of polymoprhic variants with generated map and fold  
traversals would be incredibly useful in AST transformations.

Imagine the case where some constructors are "shared" between  
different ASTs, e.g. type ty = [`A a|`B b] in one module and type ty  
= [`B b|`C c|` d] in another. You need to transform the first type  
into the second.

You could use the example below and add matches for special cases  
where either the target constructor is different or different actions  
need to be taken.

Is adding polymorphic variants to camlp4 something that can be  
accomplished by mere mortals? Any pointers on where to start and how  
to proceed?

	Thanks, Joel

On Apr 30, 2007, at 9:21 AM, Nicolas Pouillard wrote:

> However these to generators don't handle polymorphic variants.
> [...]
> class map = Camlp4Filters.GenerateMap.generated;;
> class fold = Camlp4Filters.GenerateFold.generated;;
>
> let strip_postions = object inherit map as super
>  method expr e =
>    match super#expr e with
>    | TokenPos(a, _) -> a
>    | e -> e
> end

--
http://wagerlabs.com/






  parent reply	other threads:[~2007-04-30  8:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-29 14:40 Joel Reymont
2007-04-30  8:21 ` [Caml-list] " Nicolas Pouillard
2007-04-30  8:41   ` Joel Reymont
2007-04-30  9:47     ` Nicolas Pouillard
2007-04-30  8:53   ` Joel Reymont [this message]
2007-04-30 12:19   ` Joel Reymont
2007-04-30 12:42     ` Nicolas Pouillard
2007-04-30 12:46       ` Joel Reymont
2007-04-30 12:58         ` Nicolas Pouillard
2007-04-30 13:06           ` Joel Reymont
2007-04-30 13:09             ` Nicolas Pouillard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A2FB71CF-6F3F-4DBB-B4ED-42DF51C27D5C@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=nicolas.pouillard@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).