From: "François Pottier" <francois.pottier@inria.fr>
To: Drup <drupyog+caml@zoho.com>, caml-list@inria.fr
Subject: Re: [Caml-list] [ANN] visitors
Date: Mon, 30 Jan 2017 17:04:37 +0100 [thread overview]
Message-ID: <588F6415.4000900@inria.fr> (raw)
In-Reply-To: <fc83f6ab-90a1-8ac1-7585-a15fb7fe89bd@zoho.com>
Hello,
Le 27/01/2017 23:55, Drup a écrit :
> Very nice! I wanted this for quite a while and the documentation is
> excellent.
Thanks! And thanks for your comments and pointers.
> A big difference is that it load type definition from .cmi files directly.
Indeed, a limitation of the ppx approach is that it is purely syntatic:
a syntax tree (the type definition) is turned into a syntax tree (the
definition of the visitor classes). In particular, at the moment, "visitors"
cannot generate visitor classes for a pre-existing type. Perhaps one could
write a tool that reads a .cmi file, but I suppose it would have to be
explicitly invoked as an external tool. I will think about it.
> What do you think of visitor that translates one datatype into another ?
Well, the current package already allows this.
If the two data types are just two distinct instances of a single
parameterized data type, then a "map" visitor can do this, with very little
effort. See the examples in the manual when "ordinary expressions" are
converted to "hash-consed expressions" and back.
If the two data types are unrelated, then, in order to translate the type
"foo" to the type "bar", you need a "fold" visitor for the type "foo". You
then have to manually implement each of the "build_" methods, so as to
explain
how each data constructor of the type "foo" should be translated.
> I wonder if, given some annotations, it would be doable to use similar
> techniques to generate visitors between different datatypes.
I think you have it already, but instead of placing "annotations" in the
type definition, you have to implement the "build_" methods.
--
François Pottier
francois.pottier@inria.fr
http://gallium.inria.fr/~fpottier/
next prev parent reply other threads:[~2017-01-30 16:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 17:56 François Pottier
[not found] ` <fc83f6ab-90a1-8ac1-7585-a15fb7fe89bd@zoho.com>
2017-01-30 16:04 ` François Pottier [this message]
2017-01-30 16:18 ` François Pottier
2017-01-31 9:30 ` whitequark
2017-01-31 10:26 ` François Pottier
2017-01-31 21:02 ` whitequark
2017-01-31 12:46 ` François Pottier
2017-02-01 15:50 ` Emilio Jesús Gallego Arias
2017-02-01 16:48 ` François Pottier
2017-02-01 23:49 ` whitequark
2017-02-02 0:46 ` Emilio Jesús Gallego Arias
2017-03-16 11:12 ` Kakadu
2017-03-16 15:33 ` whitequark
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=588F6415.4000900@inria.fr \
--to=francois.pottier@inria.fr \
--cc=caml-list@inria.fr \
--cc=drupyog+caml@zoho.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