Ppx by example - repo to help on ppx learning

Hey everyone!

Over the past few weeks, I’ve started my journey to learn PPX, and during this process, I found it challenging to find examples. So, I began creating my own examples and adding explanations for myself.

I realized that I could make my examples and explanations public because this would push me to learn more deeply (as I’d need to provide better and clearer explanations) and could also help anyone else on this learning path. @davesnx also encouraged me to share my process (maybe through a blog post in the future). So, I created this repository: github.com/pedrobslisboa/ppx-by-example.

The idea is to have examples and an explanation for each detail on those. It has also a brief explanation about the subject on every README.

I have a few notes:

  • It is a wip project, which means that there are parts in development. But sharing it is also a way to push me to improve this project.
  • As I said, I’m on the process of learning PPX, so probably I missed or added something wrongly, so please If you notice it, share it on the repo so I can fix.
  • I am also in the process of learning OCaml. I started coding in OCaml this year (professionally just last month), so this repository might not have the best code. If you think it can be improved, please let me know. :heart:
  • I’m not a native English speaker or the best writer. I asked ChatGPT to help fix some mistakes and improve cohesion, but if you notice anything that needs to be improved, please let me know. :heart:

Besides that, any comments, help, or additions are welcome. I hope this can be helpful :3
Thank you all!

19 Likes

Cool! :star_struck: Preprocessing is a really difficult topic. Thank you for this content!

1 Like

Indeed, my head hurt a lot when I was trying to figure out AST and PPXLib helpers."

This looks great!

I wrote a blog post quite a while ago with similar intent which you can find here: An introduction to OCaml PPX ecosystem.

We wanted to start integrating all of its content, after slightly updating it, in ppxlib’s manual. We feel like it would be good to have all documentation there, including beginners guide.

You’re repo seems to be more complete and up to date. How willing would you be to contribute some or all of your documentation to ppxlib itself? We would greatly appreciate such an addition on our journey to improve our manual!

2 Likes

@NathanReb Sorry for the delay. ICFP took up a lot of my energy.

I wrote a blog post quite a while ago with similar intent which you can find here: An introduction to OCaml PPX ecosystem .

This was actually one of my references for the documentation on the repo. I need to update it to include the link to this post.

How willing would you be to contribute some or all of your documentation to ppxlib itself?

100% :3
The repo is still in WIP, but I’ll love to help on the ppxlib documentation.

2 Likes

100% :3

That’s great to hear! Let’s sync up on some more appropriate channel for this!

You might also be interested in some recent work we’ve been doing here:

We’re adding a dumpast like tool to ppxlib which can be useful for new and seasoned ppx authors alike.

We could also very easily write a similar tool to dump an AST Explorer compatible JSON version if that can be of help although I’m not quite sure how we would integrate it with AST Explorer itself.

2 Likes

Great tutorial! I liked the positive and encouraging tone :slight_smile:

I know that it can be a lot, but don’t worry; we are going step by step, and you are going to understand it.

A while ago, I tried to gain familiarity with the subject creating my own ppx but I got stuck pretty quickly. There was too much of a gap between my understanding then and a working prototype.

It took me probably a couple of hours to go through your tutorial and you made a bunch of things very clear to the uninitiated, I liked how you spelled things out (“this is a structure”, “check out AST explorer”, “here’s 3 ways to create the same node”, etc.)

So congrats, and I’m glad your work will get merged in the manual.

Having good documentation makes such a difference, we can learn the subject much more quickly :+1:

2 Likes