Closed neojski closed 8 years ago
Just added some instructions, please try and let me know of any issues.
It's helpful, now it complies. However, I tried using it as described in whitequark's blog post via:
ocamlfind ocamlc -package ppx_deriving_random examples/free_magma.ml -verbose
but it says:
Effective set of compiler predicates: pkg_ppx_deriving_random,autolink,byte
+ ocamlc.opt -verbose -I /home/neo/.opam/system/lib/ppx_deriving_random examples/free_magma.ml
File "examples/free_magma.ml", line 12, characters 23-25:
Error: Syntax error
ocamlc.opt returned with exit code 2
There was a syntax error in the example. It's odd since I've compiled and tested it in the past. I added usage instructions to the README now. The actual syntax extension is ppx_deriving_random.ppx
, as I've reserved the top-level package name for a future runtime or runtime+ppx. The free_magma.ml
example also needs ppx_deriving.show
.
Also added the package that I had already promised in the readme. I'll try to get it into the official opam repo later, as standalone package or part of ppx_deriving [#1], after adding some suitable default random instance distributions.
Thanks, I can compile and run it now!
Great, and thanks for testing!
Maybe one last thing: how do I print the transformed source code? I'm again following the @whitequark's blog post but I don't really know how to run something similar to ocamlfind ppx_tools/rewriter ./ppx_getenv.native foo.ml
.
I got the following stub which I used for debugging:
ocamlfind ocamlopt -g -dsource \
-package ppx_deriving \
-package ppx_deriving.show \
-ppxopt ppx_deriving,../_build/ppx_deriving_random.cmxs $test
So, try to pass -dsource
. Didn't find it in the relevant man pages, so I'm not sure from where I got it.
Thank you!
@neojski Using -dsource is pretty much what I myself do. Jane Street's ppx_driver seems to make that easier if you'd like.
@paurkedal I generally put the ppx extension itself in the toplevel package (i.e. ppx_deriving_random
and the runtime, if any, in a sub-package (i.e. ppx_deriving_random.runtime
). Having two ppx's in the default package name is awkward... and if you ever want to do something non-ppx with the same codebase, I'd say just split it out into a different package (i.e. random
).
@whitequark The ppx
subpackage convention is something I took away from a discussion "META file standards for ppx extensions" on the ocaml list a few months ago. In particular, see the mail Dario Teixeira, posted 2015-04-09. Not sure how the practise will pan out, but I think it would be good to have the same kind of consistency as for camlp4 extensions. I could image a amendment of to the proposed practise, though, saying that if the package name starts with "ppx_", then the scheme in inverted.
I wanted to play with this code a little bit but I have some troubles compiling it. Would you mind adding some instructions to the README?