# Ppx lib for OCaml 5.0

**URL:** <https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550>\
**Category:** Ecosystem\
**Tags:** ppx, compiler, dune\
**Created:** [March 22, 2022, 2:09pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550 "2022-03-22T14:09:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiago\_Soares](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/tiago_soares/32/3635_2.png) [@Tiago\_Soares](https://discuss.ocaml.org/u/Tiago_Soares)\
**Post date:** [March 22, 2022, 2:09pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550/1 "2022-03-22T14:09:20Z")

</div>

Hello

I am currently doing an academic project that will require access to the parse tree for algebraic effects and handlers using ppx. Currently I was not able to find any solution using ppxlibs or compiler-libs, is there any project that has extended ppx tools to give access to the constructors related to effects?

If that is not the case, @mariopereira and I are willing to extend (at least minimally) the existing ppx ecosystem.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [March 22, 2022, 2:31pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550/2 "2022-03-22T14:31:46Z")

</div>

Note that OCaml 5.0 does not include any additional syntax for effect handlers: the Parsetree is identical to that of 4.14.

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![Tiago\_Soares](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/tiago_soares/32/3635_2.png) [@Tiago\_Soares](https://discuss.ocaml.org/u/Tiago_Soares)\
**Post date:** [March 22, 2022, 3:03pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550/3 "2022-03-22T15:03:16Z")

</div>

Hello

The title is a bit misleading, we are working in the 4.12.0+effects+domains switch, which does have syntactic support for effects and handlers. This means that when we try to install ppx lib we get the following error:

1311 | | Pstr\_eval (e, attrs) →

# 1312 | pp f “@[;;%a@]%a”

# 1313 | (expression ctxt) e

# 1314 | (item\_attributes ctxt) attrs

# …

# 1442 | | Pstr\_attribute a → floating\_attribute ctxt f a

# 1443 | | Pstr\_extension(e, a) →

# 1444 | item\_extension ctxt f e;

# 1445 | item\_attributes ctxt f a

# Warning 8 [partial-match]: this pattern-matching is not exhaustive.

# Here is an example of a case that is not matched:

# Pstr\_effect \_

Meaning we will need to rewrite ppx lib in order to use it in this switch. This is a bit of a niche problem, but we are wondering if anyone has done anything regarding this.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [March 22, 2022, 3:26pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550/4 "2022-03-22T15:26:26Z")

</div>

If I understand correctly `4.12.0+effects+domains` was a testbed for lots of the developments that lead to OCaml 5.0, it is not representative of OCaml 5.0 and as @nojb said, in 5.0 there won’t be any syntax extensions for effects.

This doesn’t mean that they won’t be introduced eventually, maybe in future releases and at that time the PPX tooling will most likely support that. It might match the syntax of `4.12.0+effects+domains` but it also might not, so I would recommend against using an abandoned prototype to base your work on.

---

<div class="post-metadata">

**Author:** ![avsm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/avsm/32/6_2.png) [@avsm](https://discuss.ocaml.org/u/avsm)\
**Post date:** [March 23, 2022, 3:39pm UTC](https://discuss.ocaml.org/t/ppx-lib-for-ocaml-5-0/9550/5 "2022-03-23T15:39:33Z")

</div>

There’s a patch to ppxlib.0.22.0 to make it work with 4.12.0+domains+effects [here](https://github.com/ocaml-multicore/multicore-opam/blob/master/packages/ppxlib/ppxlib.0.22.0%2Beffect-syntax/files/0001-compiles-with-multicore.patch), but I’d be very surprised if it hasn’t bitrotted with more recent ppxlib releases. As others have noted in this thread, the effect syntax is nice, but has no future in OCaml 5.0, so bear that in mind before using it in new code.
