View on GitHub Edit this page

OCamlverse

Documenting everything about OCaml

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.

  • ppxlib: The modern solution for writing PPX extensions. Without this library, writing PPX extensions is fragile and breaks with OCaml version changes. ppxlib merges several older projects together to provide a complete platform for writing efficient, resilient PPX extensions.

Articles

Extensions

  • ppx_deriving: Type-based framework for ppx extensions. Contains built-in plugins for show, eq, ord, enum, iter, map, fold, and make.
  • 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.
  • ppx_regex: Contains 2 ppx parsers to OCaml regex libraries:
    • ppx_regexp: maps to use Re (untyped regex)
    • ppx_tyre: maps to use Tyre for typed regex.

Other

  • cppo: A simple C++-like preprocessor for OCaml files.
  • 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.
  • camlp4: Camlp4 is an older way of modifying OCaml syntax and applying metaprogramming. It is generally discouraged nowadays – use ppx instead.
  • camlp5: Another variant of metaprogramming that is discouraged nowadays.