Skip to content

ppxlib simple example, minimal boilerplate to write a ppx. Using esy and alcotest for testing.

License

Notifications You must be signed in to change notification settings

ml-in-barcelona/ppxlib-simple-example

Repository files navigation

ppxlib-simple-example

A simple ppx to examplify the initial setup of ppxlib, part of the talk The needed introduction to writing a ppx given at Reason STHLM Meetup..

It uses opam

  • OCaml 5.2.0
  • dune 3.12
  • ppxlib 0.27

Installation

make install

Building

make build # Builds the project, once
make dev # Watch the filesystem and re-builds the project on each change

Testing

make test # Runs snapshot tests
make test-watch # Watch the filesystem and re-runs the tests on each change
make test-update # Updates the snapshot tests

Usage

Users of your ppx need to add the ppx name to their dune stanza:

(preprocess
  (pps ppx-simple-example))

And then you can use it in your code:

print_endline [%yay]
(* Transforms to *)
print_endline "Hello future compiler engineer!"

About

ppxlib simple example, minimal boilerplate to write a ppx. Using esy and alcotest for testing.

Topics

Resources

License

Stars

Watchers

Forks