Resources for Learning CamlP4

For an accessible introduction to modern (>= 3.10) Camlp4, you may be interested in Jake Donham’s blog post series “Reading Camlp4” :
You will also find valuable (though incomplete) information on the camlp4 wiki :
The older version of camlp4 (< 3.10, now called camlp5) also provides a documentation , and you can also use to Martin Jambon’s tutorial (for the older camlp4).

— bluestorm

You can also see the articles in sequence at

which I recommend since later articles depend on earlier material.

— Jake Donham

Shameless self-plug, but I wrote a blog post this summer about my experience figuring out how to do it. I provide a walk-through and explanation of a minimal syntax extension which adds lazy list pattern matching support based on Batteries. The URL:
I do assume a basic knowledge of parsing context-free grammars, but a generic tutorial on parsing with a tool such as Yacc can fill in that gap. The Wikipedia article[1] may also be helpful.
Once you’ve lept the hurdle of figuring out what pieces you need to write and build a syntax extension, the remaining tricky part is to figure out what pieces of the grammar you need to extend to accomplish your objective. For that, I consult the definition of the OCaml parser in in the OCaml source tree.

— Michael Ekstrand

If you consider yourself as a n00b, don’t start by camlp4. This is probably the most difficult part of OCaml — and to program camlp4 you need to use OCaml standard syntax (or revised syntax, it depends if you
use antiquotations).
If you still want to follow the hard path, as suggested elsewhere, Jake Donham’s blog posts are very good:
Or if you are around, there is a tutorial session at CUFP:
(but you need to subscribe).

— Sylvain Le Gall
(via Caml-list)

Leave a Reply

Your email address will not be published. Required fields are marked *