package ppx_hegel_compat
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=d9f942e6f52eebae812a7de84ca8925c
sha512=07516c2970feebd58c10d4ad0390dbc9ab083f94b46b11ab4be6ddd162105dd52ab992f22042efb32595fe7ff5ee0b956c3f6a7af4b8b817865681724edc6426
doc/ppx_hegel_compat/Ppx_compat/index.html
Module Ppx_compatSource
Platform compatibility shim for ppxlib types.
On OxCaml, ppxlib's AST types differ from standard OCaml (labeled tuples, constructor modalities, etc.). This module abstracts over those differences so the PPX deriver can work on both platforms.
extract_tuple_types ct returns Some types if ct is a tuple type, None otherwise. On OxCaml, strips the optional labels from labeled tuples.
type constr_args = | Tuple of Ppxlib.core_type list(*Positional arguments (
*)C of t1 * t2).| Record of Ppxlib.label_declaration list(*Inline-record arguments (
*)C of { f : t }).
Constructor arguments with a uniform representation on every platform.
extract_constr_args args converts constructor_arguments to constr_args. On OxCaml, extracts the core types from constructor_argument records.
val map_constr_arg_types :
(Ppxlib.core_type -> Ppxlib.core_type) ->
Ppxlib.constructor_arguments ->
Ppxlib.constructor_argumentsmap_constr_arg_types f args applies f to each argument core type of args, in both the tuple and the inline-record form.
val sexp_of_str_type_decl :
loc:Ppxlib.Location.t ->
path:string ->
(Ppxlib.rec_flag * Ppxlib.type_declaration list) ->
Ppxlib.structuresexp_of_str_type_decl ~loc ~path decls emits sexp_of_<t> definitions for decls through ppx_sexp_conv's expander. On OxCaml, fills the extra mode arguments (unboxed/stackify/portable/localize) with false.
extract_expr_tuple e returns Some es if e is a tuple expression, None otherwise. On OxCaml, strips the optional labels from labeled tuples.
unwrap_pattern_constraint pat returns Some inner if pat is a type-constraint pattern ((p : ty)), None otherwise. On OxCaml, Ppat_constraint carries an extra modes argument.
expr_first_param_pat e returns Some pat for the pattern of the first value parameter of a function expression e (fun pat … -> …), or None if e is not a function or has no value parameter. Abstracts over the OxCaml Pexp_function/standard Pexp_fun split.
peel_fun_params e strips the leading value-parameter lambdas of e and returns the function body, or e unchanged when it is not such a function.
is_function_expr e is true when e is a function literal (fun … -> … or function …).
extract_let_bindings e returns Some vbs if e is a let … in … expression, None otherwise. On OxCaml, Pexp_let carries an extra mutable_flag.
val map_let_value_bindings :
(Ppxlib.value_binding list -> Ppxlib.value_binding list) ->
Ppxlib.expression ->
Ppxlib.expressionmap_let_value_bindings f e rewrites the bindings of a let … in … expression e with f, preserving every other field (recursion flag, body, and the OxCaml-only mutable_flag); returns e unchanged if it is not a let.