When contributing to this repository, please first discuss the change you wish to make via issue or any other method with the owners of this repository before making a change.
PPXs are not the easiest to work with, especially if it's your first time writing one. Don't be afraid to ask for help by commenting on a related GitHub issue or in the Discord: https://discord.gg/SmsJyCdH2h.
- git clone https://github.com/reasonml-labs/decco
- cd decco
- yarn install
- See the steps below to get ocaml set up
- yarn build-ppx
- Open the PR
In order to see what are the scripts available on the repository, run yarn run
. It will render a list of available commands in order to build the project, build the ppx, etc.
Note: Wasn't able to install ocaml-lsp-server with esy, instead can use opam.
ocaml-lsp-server
is only needed for development.
You would need to have opam installed.
- cd ppx_src;
- opam switch create . 4.12.1 --deps-only # If it's the first time you create a switch it can take a while.
- eval $(opam env)
- opam install -y . --deps-only
- Profit, this should make your editor a little more smart
Unit testing is done in ReScript and rescript-jest, lives under test/__tests__
.
Working on PPXs can be a real pain because you don't get to easily see the product of your work. There are some tools to help though.
See the output of your PPX as ReScript code by running yarn run preview-ppx <file name>
Gotcha: This PPX'd output isn't ReScript syntax generated by the PPX. The PPX runs on the AST, which is OCaml. What you see here is the result of the transformed AST rendered back into ReScript by the compiler's formatting tool
If you want to see what's really going on under the hood, read more:
See a text representation of the tree you're really operating on, and the real results of your PPX by running yarn run print-parse-tree-with-ppx <file name>
You'll probably get compiler errors, because that's calling a private API of bsc that isn't including dependencies. But your goal here is really just to inspect the tree.
I suggest that when you're trying to get something written, you write the ReScript syntax for what you're trying to achieve, inspect its AST using the command above, and then use the same command on your PPX to see what you're actually getting.