No-arguments pattern in Ast_pattern
Hello, I am trying to write a ppx that essentially just drop-in replaces the expression [%operating_system] to a string which represents the operating system the user is running on.
In skeleton/pseudocode, this was the idea I was trying to go for:
open Ppxlib
let name = "operating_system"
let expand ~loc ~path:_ (env : string) =
Ast_builder.Default.estring s ~loc
let ext =
Extension.declare
name
Extension.Context.expression
____
expand
let () = Ppxlib.Driver.register_transformation name ~extensions:[ext]
However, I'm not sure what to put where the ____ is if I don't require any arguments to be passed into my expression. Is there a way to do this without using more direct language hooks?
I believe you're looking for this pattern:
Ast_pattern.(pstr nil)
Although it's not clear to me what you're trying to accomplish. Why can't you just use a normal let binding for the detected operating system?
Hello @zbaylin, has your question been answered back then?