Skip to content
Switch branches/tags

Latest commit



Failed to load latest commit information.
Latest commit message
Commit time

Build status: status.

OCaml macros


This is an experimental implementation of OCaml macros, originally designed by Leo White and Jeremy Yallop (original paper). The best place to learn more is probably this introduction post.

The current default branch is macros_with_lambda_quotes, which will eventually become the only implementation. However, for a nicer printing of quotes, you may want to use the legacy branch macros_old until prettier printing is implemented in this branch.


Installation instruction are the same as for the standard OCaml distribution. You can find a few examples of what is possible in the links above, or on the macros-examples repo. You can also take a look at the testsuite/tests/macros/ directory.

Installing OPAM packages

Most packages should compile fine, but causes that may break your packages include:

  • a use of the reserved words static or macro as an identifier;

  • a use of $ as a regular operator.

If you need to install Camlp4, you will have to pin it to this repository. Please be aware that this version of Camlp4 is only provided for backward-compatibility and can only generate "pre-macro" OCaml, i.e. it cannot generate any of the macro constructs.


You are very welcome to try out macros. Please do report any bugs or inconvenience by opening an issue on this repo.

Pull requests

Found a bug and know how to fix it? We certainly appreciate pull requests. If you plan on making big changes, please file an issue first to discuss why theses changes are needed.

List of Contributors

The implementation of macros is an OCaml Labs research project.

Main collaborators:

  • Olivier Nicole, main developer

  • Leo White, quoting library, original design and supervision

  • Jeremy Yallop, original design and supervision

  • Oleg Kiselyov, developer of BER MetaOCaml, from which macros are inspired

  • Gemma Gordon, project manager