From: Xavier Van de Woestyne <xavier.vdw@gmail.com>
To: Marc Lasson <marc.lasson@lexifi.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Information for writting a ppx
Date: Mon, 20 Jun 2016 08:33:05 -0700 (PDT) [thread overview]
Message-ID: <f3gx2qw6nhznmrcn9g50952ci-2147483647@mailer.nylas.com> (raw)
In-Reply-To: <94db527d-c165-7e7d-5c2d-8ed3f7f1f711@lexifi.com>
[-- Attachment #1: Type: text/plain, Size: 2152 bytes --]
Thanks for the point !
Xavier Van de Woestyne
http://xvw.github.io

On juin 20 2016, at 5:32 pm, Marc Lasson <marc.lasson@lexifi.com> wrote:
> To paraphrase the code, I just advised Xavier to use a mapper that does
> recursively not call itself.
>
> > (* Mapper for all transformation *)
> > let general_mapper = Ast_mapper.{ default_mapper with structure =
> > structure }
> >
> > (* New Mapper only for the toplevel *)
> > let toplevel_mapper =
> > Ast_mapper.{
> > default_mapper with
> > structure = fun _ str ->
> > let pl = Ast_helper.Str.eval (Ppx.Fabric.print_endline "Hello
> > World") in
> > pl :: (general_mapper.structure general_mapper str)
> > }
> > ```
>
> Note that if you do not plan to extend general_mapper with a mapper that
> actually does something you could simply write :
>
> let toplevel_mapper =
> Ast_mapper.{
> default_mapper with
> structure = fun _ str ->
> let pl = Ast_helper.Str.eval (Ppx.Fabric.print_endline "Hello
> World") in
> pl :: str
> }
>
> Also, if the ppx is also applied to compile mli interfaces, then this
> will be structures occurring within the toplevel signature (eg. in the
> payloads of attributes). So to be "safe", you should probably do :
>
> let toplevel_mapper =
> Ast_mapper.{
> default_mapper with
> signature = fun _ -> default_mapper.signature default_mapper;
> structure = fun _ str ->
> let pl = Ast_helper.Str.eval (Ppx.Fabric.print_endline "Hello
> World") in
> pl :: str
> }
>
> \--
> Marc.
>
> \--
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list:
[http://groups.yahoo.com/group/ocaml_beginners](http://groups.yahoo.com/group/ocaml_beginners&r=Y2FtbC1saXN0QGlucmlhLmZy)
> Bug reports: [http://caml.inria.fr/bin/caml-bugs](http://caml.inria.fr/bin
/caml-bugs&r=Y2FtbC1saXN0QGlucmlhLmZy)
[-- Attachment #2: Type: text/html, Size: 2768 bytes --]
prev parent reply other threads:[~2016-06-20 15:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 17:10 Xavier Van de Woestyne
2016-06-20 14:15 ` Anton Bachin
2016-06-20 15:01 ` Xavier Van de Woestyne
2016-06-20 15:31 ` Marc Lasson
2016-06-20 15:33 ` Xavier Van de Woestyne [this message]
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=f3gx2qw6nhznmrcn9g50952ci-2147483647@mailer.nylas.com \
--to=xavier.vdw@gmail.com \
--cc=caml-list@inria.fr \
--cc=marc.lasson@lexifi.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