o1-labs / ocamlbyexample

Learn Ocaml by reading code examples
https://o1-labs.github.io/ocamlbyexample/
68 stars 4 forks source link

chapter: ppx #13

Open mimoo opened 1 year ago

mimoo commented 1 year ago

you can dump any AST by doing ocamlfind ppx_tools/dumpast your_file.ml

mimoo commented 1 year ago

or ocamlfind ppx_tools/dumpast -e "1 + 1" (from https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem)

Similarly, you can use the -t or -p options to respectively pretty print ASTs from type expressions or patterns.

mimoo commented 1 year ago
Screenshot 2022-12-13 at 12 43 02 AM

(https://ocaml-ppx.github.io/ppxlib/ppxlib/manual.html#what-is-ppx)

mimoo commented 1 year ago

started here: https://github.com/o1-labs/ocamlbyexample/commit/7c6a95ddc67b6dd827172e87c735a95ed97f53dc