Ast_builder.DefaultHelpers taking a ~loc argument. This module is meant to be opened or aliased.
module Located : sig ... endval class_infos :
loc:Warnings.loc ->
virt:Migrate_parsetree.Ast_412.Asttypes.virtual_flag ->
params:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* (Migrate_parsetree.Ast_412.Asttypes.variance
* Migrate_parsetree.Ast_412.Asttypes.injectivity))
list ->
name:string Location.loc ->
expr:'a ->
'a Migrate_parsetree.Ast_412.Parsetree.class_infosval pexp_for :
loc:Warnings.loc ->
Migrate_parsetree.Ast_412.Parsetree.pattern ->
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Asttypes.direction_flag ->
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Parsetree.expressionval location :
start:Lexing.position ->
end_:Lexing.position ->
ghost:bool ->
Warnings.locval position :
fname:string ->
lnum:int ->
bol:int ->
cnum:int ->
Lexing.positionval type_declaration :
loc:Warnings.loc ->
name:string Location.loc ->
params:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* (Migrate_parsetree.Ast_412.Asttypes.variance
* Migrate_parsetree.Ast_412.Asttypes.injectivity))
list ->
cstrs:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* Migrate_parsetree.Ast_412.Parsetree.core_type
* Warnings.loc)
list ->
kind:Migrate_parsetree.Ast_412.Parsetree.type_kind ->
private_:Migrate_parsetree.Ast_412.Asttypes.private_flag ->
manifest:Migrate_parsetree.Ast_412.Parsetree.core_type option ->
Migrate_parsetree.Ast_412.Parsetree.type_declarationval type_extension :
loc:Warnings.loc ->
path:Ppxlib_ast__.Import.Longident.t Location.loc ->
params:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* (Migrate_parsetree.Ast_412.Asttypes.variance
* Migrate_parsetree.Ast_412.Asttypes.injectivity))
list ->
constructors:Migrate_parsetree.Ast_412.Parsetree.extension_constructor list ->
private_:Migrate_parsetree.Ast_412.Asttypes.private_flag ->
Migrate_parsetree.Ast_412.Parsetree.type_extensionval eint :
loc:Location.t ->
int ->
Migrate_parsetree.Ast_412.Parsetree.expressionval echar :
loc:Location.t ->
char ->
Migrate_parsetree.Ast_412.Parsetree.expressionval estring :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.expressionval efloat :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.expressionval eint32 :
loc:Location.t ->
int32 ->
Migrate_parsetree.Ast_412.Parsetree.expressionval eint64 :
loc:Location.t ->
int64 ->
Migrate_parsetree.Ast_412.Parsetree.expressionval enativeint :
loc:Location.t ->
nativeint ->
Migrate_parsetree.Ast_412.Parsetree.expressionval ebool :
loc:Location.t ->
bool ->
Migrate_parsetree.Ast_412.Parsetree.expressionval pint : loc:Location.t -> int -> Migrate_parsetree.Ast_412.Parsetree.patternval pchar :
loc:Location.t ->
char ->
Migrate_parsetree.Ast_412.Parsetree.patternval pstring :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.patternval pfloat :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.patternval pint32 :
loc:Location.t ->
int32 ->
Migrate_parsetree.Ast_412.Parsetree.patternval pint64 :
loc:Location.t ->
int64 ->
Migrate_parsetree.Ast_412.Parsetree.patternval pnativeint :
loc:Location.t ->
nativeint ->
Migrate_parsetree.Ast_412.Parsetree.patternval pbool :
loc:Location.t ->
bool ->
Migrate_parsetree.Ast_412.Parsetree.patternval eunit : loc:Location.t -> Migrate_parsetree.Ast_412.Parsetree.expressionval punit : loc:Location.t -> Migrate_parsetree.Ast_412.Parsetree.patternval evar :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.expressionevar 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 :
loc:Location.t ->
string ->
Migrate_parsetree.Ast_412.Parsetree.patternval eapply :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Parsetree.expression list ->
Migrate_parsetree.Ast_412.Parsetree.expressionSame as pexp_apply but without labels
val eabstract :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.pattern list ->
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Parsetree.expressionval esequence :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.expression list ->
Migrate_parsetree.Ast_412.Parsetree.expressionval ppat_tuple_opt :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.pattern list ->
Migrate_parsetree.Ast_412.Parsetree.pattern optionval pexp_tuple_opt :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.expression list ->
Migrate_parsetree.Ast_412.Parsetree.expression optionval elist :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.expression list ->
Migrate_parsetree.Ast_412.Parsetree.expressionval plist :
loc:Location.t ->
Migrate_parsetree.Ast_412.Parsetree.pattern list ->
Migrate_parsetree.Ast_412.Parsetree.patternval pstr_value_list :
loc:Location.t ->
Ppxlib__.Import.Asttypes.rec_flag ->
Migrate_parsetree.Ast_412.Parsetree.value_binding list ->
Migrate_parsetree.Ast_412.Parsetree.structure_item listpstr_value_list ~loc rf vbs = pstr_value ~loc rf vbs if vbs <> [], [] otherwise.
val nonrec_type_declaration :
loc:Location.t ->
name:string Loc.t ->
params:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* Ppxlib__.Import.Asttypes.variance)
list ->
cstrs:
(Migrate_parsetree.Ast_412.Parsetree.core_type
* Migrate_parsetree.Ast_412.Parsetree.core_type
* Location.t)
list ->
kind:Migrate_parsetree.Ast_412.Parsetree.type_kind ->
private_:Ppxlib__.Import.Asttypes.private_flag ->
manifest:Migrate_parsetree.Ast_412.Parsetree.core_type option ->
Migrate_parsetree.Ast_412.Parsetree.type_declarationval unapplied_type_constr_conv :
loc:Location.t ->
Longident.t Loc.t ->
f:(string -> string) ->
Migrate_parsetree.Ast_412.Parsetree.expressionunapplied_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:
type_constr_conv also applies it to a list of expression, which both prevents the compiler from allocating useless closures, and almost always what is needed, since type constructors are always applied.val type_constr_conv :
loc:Location.t ->
Longident.t Loc.t ->
f:(string -> string) ->
Migrate_parsetree.Ast_412.Parsetree.expression list ->
Migrate_parsetree.Ast_412.Parsetree.expressionval eta_reduce :
Migrate_parsetree.Ast_412.Parsetree.expression ->
Migrate_parsetree.Ast_412.Parsetree.expression optionTries 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:
f has optional arguments, eta-expanding f can drop themf does side effects before receiving all its arguments, and if the eta-expansion is partially applied, eta-reducing could change behavior.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.