ocaml-ppx / ppx_tools

Tools for authors of ppx rewriters
MIT License
134 stars 39 forks source link

Add [%stri] structure item pattern and expression quotation #5

Closed whitequark closed 10 years ago

whitequark commented 10 years ago

I found that it greatly simplifies code that works on structure item level, e.g. in lwt.ppx:

structure_item = (fun mapper stri ->
  match stri with
  | [%stri let%lwt [%p? var] = [%e? exp]] ->
    [%stri let [%p var] = Lwt_main.run [%e exp]]
  | x -> default_mapper.structure_item mapper x)