Compile-Time Transformations or Reflections

Does ReScript plan or have a way to have compile-time transformations that depend on AST of expressions without changes to project settings (thus more comfortable to have little snippets of them inside code compared to PPX)?

If not, would an attempt to contribute (a subset of) that’s similar to Rust’s macro_rules allowance (maybe with procedural macros-like body instead) be receptible?


I think this would be great to have. Macros are usually not advisable, but handwriting all types for GraphQL for instance is error prone and is better done inside a macro/ppx. Without graphql-ppx my company would have never adopted Reason/Rescript. Almost all platform that have had massive success relied on metaprogramming to add productivity wins (Rails, Elixir, Rust). PPX’s are quite heavy handed though so I’d love to have a metaprogramming facility that is similarly powerful but more integrated in the language.


Exactly, where available, they have been utilized: TypeScript decorators, Template Haskell, Python decorators, Rust procedural macros are a few. I think a facility like metafunctions in Haskell would be a great, controlled, feasible introduction in the paradigm of functional programming. ReScript already has the necessary modules akin to code parser, etc. exposed; we just need to agree on a non-intrusive syntax and run them at compile-time.