Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ml-in-barcelona/ppxlib-simple-example
ppxlib simple example, minimal boilerplate to write a ppx. Using esy and alcotest for testing.
https://github.com/ml-in-barcelona/ppxlib-simple-example
alcotest ocaml ppx ppx-extension ppxlib
Last synced: about 2 months ago
JSON representation
ppxlib simple example, minimal boilerplate to write a ppx. Using esy and alcotest for testing.
- Host: GitHub
- URL: https://github.com/ml-in-barcelona/ppxlib-simple-example
- Owner: ml-in-barcelona
- License: bsd-2-clause
- Created: 2020-11-10T14:52:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-18T10:39:43.000Z (12 months ago)
- Last Synced: 2024-04-14T09:31:54.978Z (9 months ago)
- Topics: alcotest, ocaml, ppx, ppx-extension, ppxlib
- Language: OCaml
- Homepage:
- Size: 149 KB
- Stars: 11
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ppxlib-simple-example
A simple ppx to examplify the initial setup of [ppxlib](https://github.com/ocaml-ppx/ppxlib/), part of the talk [**The needed introduction to writing a ppx**](https://youtu.be/dMoRMqQ6GLs?t=4184) given at [Reason STHLM Meetup](https://www.meetup.com/es-ES/ReasonSTHLM/)..
It uses [`esy`](https://esy.sh) since it's a little easier to install sandboxes enviroments than opam.
- OCaml 4.14
- dune 3.4.1
- ppxlib 0.27## Installation
Needs `esy` installed globally in your system, if you don't have it install it with npm: `npm install -g esy`.
```bash
esy # Installs the dependencies and builds the project
```## Editor
```bash
esy add @opam/ocaml-lsp-server
```## Building
```bash
esy build # Builds the project, once
esy watch # Watch the filesystem and re-builds the project on each change
```## Testing
```bash
esy test # Runs alcotest tests
```## Usage
Users of your ppx need to add this to their dune for your executable to be executed as ppx (or inside bsconfig if targeting ReScript).
```lisp
(preprocess
(pps simple-ppx))
``````ocaml
print_endline [%yay]
(* Transforms to *)
print_endline "r3p14ccd 70 r4nd0m 5tr1n9"
```