Home

PPX

PPX, commonly written ppx, denotes the PreProcessor eXtensions framework in OCaml that enables syntax and code transformations through rewriters that operate on the compiler's abstract syntax tree. Rather than writing in language-level syntax, developers implement small programs, or "rewriters," that receive OCaml AST nodes as input and emit transformed AST that the compiler subsequently compiles.

PPX rewriters are invoked during the build process, typically via the -ppx option provided by the OCaml

The PPX ecosystem emerged to provide safe, modular, and reusable extensions, replacing earlier approaches such as

Popular PPX packages include ppx_deriving, which automatically generates boilerplate such as equality, comparison, or pretty-printing functions;

See also OCaml, Dune, Camlp4, ppx_deriving, ppxlib.

compiler
or
by
build
systems
such
as
Dune,
which
can
automatically
apply
registered
ppx
rewriters.
Camlp4.
PPX
rewriters
can
implement
features
like
automatic
derivations,
syntax
sugar,
or
domain-specific
code
generation.
others
provide
let
or
binding
syntax,
test
infrastructure,
or
inline
optimizations.
The
modern
tooling
centers
on
ppxlib,
a
library
that
simplifies
creating
rewriters,
and
a
set
of
conventions
and
runtimes
that
package
rewriters
for
use
with
Dune
and
OCaml's
compiler
toolchain.