I am trying to use some ppx in files that are compiled by bucklescript. bsb
doesn’t have a very good support for ppx. So I have to do things “by hand” and the old way, as bucklescript is using ocaml 4.02.3. I think that the question is not bucklescript specific thought. It is more about how ppx are working in general.
bsb
configuration expects a path to a ppx or a script and will apply it to every file. In my case, I don’t have my own ppx. The goal is to use ppx_deriving with some plugins and later some other existing ppx. So a script is used. It works fine when using annotation like [@@deriving ord]
.
`ocamlfind query ppx_deriving`/ppx_deriving \
`ocamlfind query ppx_deriving`/ppx_deriving_show.cma \
`ocamlfind query ppx_deriving`/ppx_deriving_ord.cma \
`ocamlfind query ppx_deriving`/ppx_deriving_eq.cma \
`ocamlfind query ppx_deriving`/ppx_deriving_map.cma \
`ocamlfind query ppx_deriving`/ppx_deriving_make.cma \
$@
Now I’d like to add ppx_enumerate`. If I understand correctly, ppx_enumerate is a plugin to ppx_deriving. So I thought that adding a few cma to the previous script would work without problem. Here is what I came for to use ppx_enumerate:
`ocamlfind query ppx_deriving`/ppx_deriving \
`ocamlfind query ppx_core`/ppx_core.cma \
`ocamlfind query ppx_optcomp`/ppx_optcomp.cma \
`ocamlfind query ppx_driver`/ppx_driver.cma \
`ocamlfind query ppx_type_conv`/ppx_type_conv.cma \
`ocamlfind query ppx_enumerate`/ppx_enumerate.cma \
$@
But when I try to compile my project using this script, I get an error:
Error: Cannot locate deriver enumerate
At this point I am stuck. I don’t know how to debug further.
- How can I check what is really included in my ppx?
- Am I calling ppx_deriving the good way?
- Is it ok to use
ppx_driver.cma
with ppx_deriving? I saw in a few META files a message about ppx_driver. In ppx_optcomp for example:error(ppx_driver) = "Cannot use ppx_optcomp.for_ppx_deriving when ppx_driver is set"
- What is the good documentation to read to understand all this?
Thanks for your help