Metaprogramming

PPX Syntax Extensions

ppx is the syntax extension format supported currently by OCaml. It replaces older techniques such as Camlp4 by limiting the scope of language extensions and dedicating to them a specific syntax.

  • OCaml-migrate-parsetree After a while, it was found that ppx extensions are rather fragile, as they target the AST, which can often change between OCaml versions. In response, OCaml-migrate-parsetree (OMP) was developed, which stabilizes ppx extensions by translating them between AST versions. Every ppx extension should now use OMP as its driver.

Articles

Extensions

  • ppx_import – Import is a syntax extension that allows to pull in types or signatures from other compiled interface files.
  • ppx_string_interpolate – A simple ppx filter to support string interpolation like `[%str "value of foo is $(foo)"]`.
  • ppx_monad – Monad syntax extension for OCaml.
  • ppx_deriving_yojson – A Yojson codec generator for OCaml.

Other

  • MetaOCaml – an OCaml dialect for multi-stage programming.
  • Fan – Fan is a compile-time metaprogramming system for OCaml, originally inspired from Camlp4. It's a combination of OCaml and Lispy Macros. It shares the same concrete syntax with OCaml.
  • camlp5 - Camlp5 is a preprocessor-pretty-printer of OCaml.
  • camlp4 - Camlp4 is part of the standard OCaml distribution and is different from Camlp5.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License