Module type Ppxlib__Ast_builder_intf.Additional_helpers

type 'a with_loc
val eint : (Ppxlib__.Import.int ‑> Ppxlib__.Import.expression) with_loc
val echar : (Ppxlib__.Import.char ‑> Ppxlib__.Import.expression) with_loc
val estring : (Ppxlib__.Import.string ‑> Ppxlib__.Import.expression) with_loc
val efloat : (Ppxlib__.Import.string ‑> Ppxlib__.Import.expression) with_loc
val eint32 : (Ppxlib__.Import.int32 ‑> Ppxlib__.Import.expression) with_loc
val eint64 : (Ppxlib__.Import.int64 ‑> Ppxlib__.Import.expression) with_loc
val enativeint : (Ppxlib__.Import.nativeint ‑> Ppxlib__.Import.expression) with_loc
val ebool : (Ppxlib__.Import.bool ‑> Ppxlib__.Import.expression) with_loc
val pint : (Ppxlib__.Import.int ‑> Ppxlib__.Import.pattern) with_loc
val pchar : (Ppxlib__.Import.char ‑> Ppxlib__.Import.pattern) with_loc
val pstring : (Ppxlib__.Import.string ‑> Ppxlib__.Import.pattern) with_loc
val pfloat : (Ppxlib__.Import.string ‑> Ppxlib__.Import.pattern) with_loc
val pint32 : (Ppxlib__.Import.int32 ‑> Ppxlib__.Import.pattern) with_loc
val pint64 : (Ppxlib__.Import.int64 ‑> Ppxlib__.Import.pattern) with_loc
val pnativeint : (Ppxlib__.Import.nativeint ‑> Ppxlib__.Import.pattern) with_loc
val pbool : (Ppxlib__.Import.bool ‑> Ppxlib__.Import.pattern) with_loc
val eunit : Ppxlib__.Import.expression with_loc
val punit : Ppxlib__.Import.pattern with_loc
val evar : (Ppxlib__.Import.string ‑> Ppxlib__.Import.expression) with_loc

evar id produces a Pexp_ident _ expression, it parses its input so you can pass any dot-separated identifier, for instance: evar ~loc "Foo.bar".

val pvar : (Ppxlib__.Import.string ‑> Ppxlib__.Import.pattern) with_loc
val eapply : (Ppxlib__.Import.expression ‑> Ppxlib__.Import.expression Ppxlib__.Import.list ‑> Ppxlib__.Import.expression) with_loc

Same as pexp_apply but without labels

val eabstract : (Ppxlib__.Import.pattern Ppxlib__.Import.list ‑> Ppxlib__.Import.expression ‑> Ppxlib__.Import.expression) with_loc
val esequence : (Ppxlib__.Import.expression Ppxlib__.Import.list ‑> Ppxlib__.Import.expression) with_loc
val ppat_tuple_opt : (Ppxlib__.Import.pattern Ppxlib__.Import.list ‑> Ppxlib__.Import.pattern Ppxlib__.Import.option) with_loc
val pexp_tuple_opt : (Ppxlib__.Import.expression Ppxlib__.Import.list ‑> Ppxlib__.Import.expression Ppxlib__.Import.option) with_loc
val pconstruct : Ppxlib__.Import.constructor_declaration ‑> Ppxlib__.Import.pattern Ppxlib__.Import.option ‑> Ppxlib__.Import.pattern
val econstruct : Ppxlib__.Import.constructor_declaration ‑> Ppxlib__.Import.expression Ppxlib__.Import.option ‑> Ppxlib__.Import.expression
val elist : (Ppxlib__.Import.expression Ppxlib__.Import.list ‑> Ppxlib__.Import.expression) with_loc
val plist : (Ppxlib__.Import.pattern Ppxlib__.Import.list ‑> Ppxlib__.Import.pattern) with_loc
val pstr_value_list : loc:Ppxlib.Location.t ‑> Ppxlib__.Import.Asttypes.rec_flag ‑> Ppxlib__.Import.value_binding Ppxlib__.Import.list ‑> Ppxlib__.Import.structure_item Ppxlib__.Import.list

pstr_value_list ~loc rf vbs = pstr_value ~loc rf vbs if vbs <> [], [] otherwise.

val nonrec_type_declaration : (name:Ppxlib__.Import.string Ppxlib.Loc.t ‑> params:(Ppxlib__.Import.core_type * Ppxlib__.Import.Asttypes.variance) Ppxlib__.Import.list ‑> cstrs:(Ppxlib__.Import.core_type * Ppxlib__.Import.core_type * Ppxlib.Location.t) Ppxlib__.Import.list ‑> kind:Ppxlib__.Import.type_kind ‑> private_:Ppxlib__.Import.Asttypes.private_flag ‑> manifest:Ppxlib__.Import.core_type Ppxlib__.Import.option ‑> Ppxlib__.Import.type_declaration) with_loc
val unapplied_type_constr_conv : (Ppxlib.Longident.t Ppxlib.Loc.t ‑> f:(Ppxlib__.Import.string ‑> Ppxlib__.Import.string) ‑> Ppxlib__.Import.expression) with_loc

unapplied_type_constr_conv is the standard way to map identifiers to conversion fonctions, for preprocessor that creates values that follow the structure of types. More precisely, path_conv path (sprintf "sexp_of_%s") is:

val type_constr_conv : (Ppxlib.Longident.t Ppxlib.Loc.t ‑> f:(Ppxlib__.Import.string ‑> Ppxlib__.Import.string) ‑> Ppxlib__.Import.expression Ppxlib__.Import.list ‑> Ppxlib__.Import.expression) with_loc
val eta_reduce : Ppxlib__.Import.expression ‑> Ppxlib__.Import.expression Ppxlib__.Import.option

Tries to simplify fun v1 v2 .. -> f v1 v2 .. into f. Only works when f is a path, not an arbitrary expression as that would change the meaning of the code. This can be used either for cleaning up the generated code, or to reduce allocation if f is a local variable (the compiler won't optimize the allocation of the closure).

Eta-reduction can change the types/behavior in some corner cases that are unlikely to show up in generated code:

eta_reduce_if_possible_and_nonrec is meant for the case where the resulting expression is going to be bound in a potentially recursive let-binding, where we have to keep the eta-expansion when rec_flag is Recursive to avoid a compile error.

val eta_reduce_if_possible : Ppxlib__.Import.expression ‑> Ppxlib__.Import.expression
val eta_reduce_if_possible_and_nonrec : Ppxlib__.Import.expression ‑> rec_flag:Ppxlib__.Import.rec_flag ‑> Ppxlib__.Import.expression