Ppxlib special function in module?

Hi, I am writing a PPX ‘special function’: writing-ppxs (ppxlib.writing-ppxs)

So I have it working but I’ve scoped it inside a module, eg:

# let post_order = Dream_html.Route.post "/orders/%s" (fun _ id ->
  Dream.html ~status:`Created id);;
val post_order :
  (string -> Dream.response Lwt.t, string -> Dream_html.attr)
  Dream_html.Route.t = POST /orders/%s

However, when I open Dream_html.Route, the special function name does not come into scope:

# open Dream_html.Route;;
# let get_order = get "/orders/%s" (fun _ id -> Dream.html id);;
Error: Unbound value get

Is there any way I can scope the special function inside my module in a normal way rather than having to hard-code its exact module path and name?

PPX is purely syntactic and knows nothing about scopes, especially opens which can bring into scope arbitrary things from whereever. So the usefulness of this ppxlib functionality is rather limited.
Currently there are only 5 uses on Sherlocode: Sherlocode. Four of them use it for an operator instead of an actual function name.

1 Like

Thanks! I ended up using an extender Dream_html (dream-html.Dream_html)