package ppxlib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=a51b3868029e62ff14a0f2bd8d278dacfc0c3fc5b22d484a296be90c53e4ffd7
sha512=6a6d9af49344e901cc9e6da7bcf38c2973705c8cee4cff1c64c0393e9ccc55a6abec1f58d5b56d0807939a3741bec722ee7bfc244f94619167a30438f182488a
doc/ppxlib/Ppxlib/Extension/index.html
Module Ppxlib.Extension
Source
Type of declared extensions.
val declare :
string ->
'context Context.t ->
(Astlib.Ast_412.Parsetree.payload, 'a, 'context) Ast_pattern.t ->
(loc:Location.t -> path:string -> 'a) ->
t
declare name context pattern expander
declares the extension names name
for context
.
expander
is responsible for producing the code to replace the extension in the AST. It receives as argument:
loc
: the location of the enclosing node. For instance for expression it is thepexp_loc
fieldpath
: the current module path
val declare_with_path_arg :
string ->
'context Context.t ->
(Astlib.Ast_412.Parsetree.payload, 'a, 'context) Ast_pattern.t ->
(loc:Location.t ->
path:string ->
arg:Longident.t Ppxlib_ast.Asttypes.loc option ->
'a) ->
t
Same as declare
except that the extension name takes an additional path argument. The path is the part of the name that start with a capitalized component. For instance in the following, the extension "map"
would receive the path argument Foo.Bar
:
let%map.Foo.Bar x = 1 in
...
val declare_inline :
string ->
'context Context.t ->
(Astlib.Ast_412.Parsetree.payload, 'a, 'context list) Ast_pattern.t ->
(loc:Location.t -> path:string -> 'a) ->
t
Inline the result of the expansion into its parent. Only works for these contexts:
class_field
class_type_field
signature_item
structure_item
val declare_inline_with_path_arg :
string ->
'context Context.t ->
(Astlib.Ast_412.Parsetree.payload, 'a, 'context list) Ast_pattern.t ->
(loc:Location.t ->
path:string ->
arg:Longident.t Ppxlib_ast.Asttypes.loc option ->
'a) ->
t
This module is used to implement Context_free.V1.map_top_down
Given a context and a list of extension expander, returns all the ones that are for this context.
This module allows to declare extensions that do not produce a value of the context type. This is typically useful for extensions point that depends on more things from the context than the path and location.