How to use ppx.metaquot in OCaml?

715 Views Asked by At

The command written in README.md doesn't work (The usage of ocamlfind is shown.) I understand the ppx_metaquot execution file is a kind of rewrite file, so I can translate my code using quasi quotation in this way:

ocamlfind ppx_tools/rewriter ~/.opam/system/lib/ppx_tools/ppx_metaquot  sample.ml

but this may not be an assumed way, so please tell me the correct usage.

1

There are 1 best solutions below

3
On

When wd want to use some PPX, normally wd use -package option of ocamlfind:

ocamlfind ocamlc -c -package ppx_tools.metaquot sample.ml

This compiles sample.ml using the preprocessor ppx_tools.metaquot.

If you want to see the output of PPX in human readable form, AFAIK things get a bit more complicated.:

ocamlfind ppx_tools/rewriter -ppx ~/.opam/system/lib/ppx_tools/ppx_metaquot sample.ml

or the following is better:

ocamlfind ppx_tools/rewriter -ppx `ocamlfind query ppx_tools`/ppx_metaquot sample.ml

There might be a simpler way than this but I do not know.