Convert from one complicated type(like AST) to another

There are equivalently powerful, but quite different: while rust macros allow you to define forms using regular Rust syntax (modulo some splicing operators, etc, quite similar to what you see in lisp macro systems and MetaOCaml AFAICT), ppx requires generated forms to be defined in terms of an AST model. This requires ppx authors to interact with said model and the various utilities surrounding it; it’s obviously a tractable exercise, but I don’t think anyone can claim that it’s easy in the same way that lisp and rust macros are.

(Anecdote: to date, I’ve found it to be far easier to simply push code generation (producing types and associated data structures from predefined JSON files for example) to bespoke separate programs that Format.printf code to where it needs to go, and tied together with dune rules. Doing the same thing via ppx was just much more complicated and touched types and APIs that I knew I wasn’t going to recall in the slightest the week after, nevermind a year from now.)

I’d call Turnstile an extension of Racket macros, but the fact that both “extension” and “application” net out to the same thing points to the essential benefit of lisp-style metaprogramming.

Thanks for the TyperML reference, that looks very interesting!

Not pitiful, but IMO unfortunate. I want to have my cake and eat it too!

1 Like