All Projects → jchavarri → hello-ppx-esy

jchavarri / hello-ppx-esy

Licence: MIT license
A simple example of a ppx with Reason and esy

Programming Languages

javascript
184084 projects - #8 most used programming language
reason
219 projects

Projects that are alternatives of or similar to hello-ppx-esy

bs-getenv
ReasonML/BuckleScript PPX for embedding env variables
Stars: ✭ 25 (-34.21%)
Mutual labels:  ppx, reasonml
awesome-ppx-reasonml
curated list of reasonml PPX rewriter
Stars: ✭ 28 (-26.32%)
Mutual labels:  ppx, reasonml
react-rules-of-hooks-ppx
This ppx validates the rules of React hooks.
Stars: ✭ 40 (+5.26%)
Mutual labels:  ppx, reasonml
jsoo-react
js_of_ocaml bindings for ReactJS. Based on ReasonReact.
Stars: ✭ 126 (+231.58%)
Mutual labels:  ppx, reasonml
reform
📋 Reasonably making forms sound good
Stars: ✭ 345 (+807.89%)
Mutual labels:  reasonml
remachine
[WIP] Reason pattern matching viz
Stars: ✭ 44 (+15.79%)
Mutual labels:  reasonml
reason-react-lazy-loading
Example project to show how to use components lazy loading in ReasonReact
Stars: ✭ 41 (+7.89%)
Mutual labels:  reasonml
reason-rust-scraper
🦀 Scraping & crawling websites using Rust, and ReasonML
Stars: ✭ 21 (-44.74%)
Mutual labels:  reasonml
Reason-react-hooks
🧶 Some hooks in ReasonML for reason-react that can be useful
Stars: ✭ 14 (-63.16%)
Mutual labels:  reasonml
ppx rapper
Syntax extension for writing SQL in OCaml
Stars: ✭ 91 (+139.47%)
Mutual labels:  reasonml
LifeTime
LifeTime app
Stars: ✭ 35 (-7.89%)
Mutual labels:  reasonml
rx-reason
Reactive programming library for ReasonML/OCaml
Stars: ✭ 49 (+28.95%)
Mutual labels:  reasonml
reason-vue
ReasonML and Vue
Stars: ✭ 55 (+44.74%)
Mutual labels:  reasonml
bs-dynamic-import
📦🚀 BuckleScript dynamic import interop on JavaScript environment
Stars: ✭ 31 (-18.42%)
Mutual labels:  reasonml
genTypeScript
Auto generation of type-safe bindings between Reason and Typescript.
Stars: ✭ 75 (+97.37%)
Mutual labels:  reasonml
reasonml-tic-tac-toe
www.imandra.ai
Stars: ✭ 19 (-50%)
Mutual labels:  reasonml
gobi
Compile OCaml/Reason to static iOS libraries
Stars: ✭ 25 (-34.21%)
Mutual labels:  reasonml
sonos-wejay
Slack integration for a local Sonos system
Stars: ✭ 19 (-50%)
Mutual labels:  reasonml
ogaml
Ocaml multimedia library
Stars: ✭ 28 (-26.32%)
Mutual labels:  reasonml
JsonCodec
JSON combinator library for BuckleScript/Reason
Stars: ✭ 38 (+0%)
Mutual labels:  reasonml

hello-ppx-esy

A project that includes the minimum configuration for a ppx called ppx_42, a project that uses Reason and Esy.

ppx_42 implements a very basic ppx that transforms the [%gimme] extension into the number literal 42.

So, the code:

let fourtyTwo = string_of_int([%gimme]);

Is transformed into:

let fourtyTwo = string_of_int(42);

Files and folders

The example contains a couple of different targets that will be handled by dune (an OCaml build system) to use the ppx in different projects:

  • The library: located under lib folder. It is used directly by native projects, and indirectly by BuckleScript projects
  • The standalone binary: BuckleScript does not provide a way to compose multiple ppxs together, so each ppx gets called individually, getting a serialized version of the AST, using the -ppx compiler flag behind the scenes. This can be configured in BuckleScript projects by using the ppx-flags key in bsconfig.json (see "Examples" section below).

For this reason, ppx_42 exposes an executable that can be consumed by BuckleScript projects.

Libraries used

ocaml-migrate-parsetree

ocaml-migrate-parsetree allows to transform between different versions of OCaml ASTs (abstract syntax tree). This enables the ppx to work with even future versions of the compiler, both in BuckleScript and in native.

For more information about this, check this post by @aantron: https://reasonml.chat/t/ppx-no-need-for-separate-ppx-and-ppx6-with-ocaml-migrate-parsetree-1-6-0/2210.

metaquot

metaquot is a ppx for ppxs 💥.

It has many use cases, but the main one is that it allows to create new AST nodes just by using plain syntax.

So instead of writing:

Ast_helper.Exp.constant(Pconst_integer("42", None));

One can write:

[%expr 42];

The metaquot ppx will take care of "expanding" the literal into the fully fleshed AST node. To know more: https://ppxlib.readthedocs.io/en/latest/ppx-for-plugin-authors.html.

Examples

The repo contains a couple of demo examples that show one way to consume the ppx from both BuckleScript and native environments.

Check the readmes on each example folder:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].