Ast_builder.MakeBuild Ast helpers with the location argument factorized.
module Located : sig ... endval loc : Location.tval attribute : name:string Location.loc -> payload:Migrate_parsetree.Ast_412.Parsetree.payload -> Migrate_parsetree.Ast_412.Parsetree.attributeval binding_op : op:string Location.loc -> pat:Migrate_parsetree.Ast_412.Parsetree.pattern -> exp:Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.binding_opval case : lhs:Migrate_parsetree.Ast_412.Parsetree.pattern -> guard:Migrate_parsetree.Ast_412.Parsetree.expression option -> rhs:Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.caseval pcl_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_exprval pcf_inherit : Migrate_parsetree.Ast_412.Asttypes.override_flag -> Migrate_parsetree.Ast_412.Parsetree.class_expr -> string Location.loc option -> Migrate_parsetree.Ast_412.Parsetree.class_fieldval pcf_initializer : Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.class_fieldval pcf_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.class_fieldval pcf_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_fieldval class_infos : 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 class_signature : self:Migrate_parsetree.Ast_412.Parsetree.core_type -> fields:Migrate_parsetree.Ast_412.Parsetree.class_type_field list -> Migrate_parsetree.Ast_412.Parsetree.class_signatureval class_structure : self:Migrate_parsetree.Ast_412.Parsetree.pattern -> fields:Migrate_parsetree.Ast_412.Parsetree.class_field list -> Migrate_parsetree.Ast_412.Parsetree.class_structureval pcty_constr : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.class_typeval pcty_signature : Migrate_parsetree.Ast_412.Parsetree.class_signature -> Migrate_parsetree.Ast_412.Parsetree.class_typeval pcty_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_typeval pctf_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.class_type_fieldval pctf_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_type_fieldval constructor_declaration : name:string Location.loc -> args:Migrate_parsetree.Ast_412.Parsetree.constructor_arguments -> res:Migrate_parsetree.Ast_412.Parsetree.core_type option -> Migrate_parsetree.Ast_412.Parsetree.constructor_declarationval ptyp_any : Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_var : string -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_tuple : Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_constr : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_alias : Migrate_parsetree.Ast_412.Parsetree.core_type -> string -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_variant : Migrate_parsetree.Ast_412.Parsetree.row_field list -> Migrate_parsetree.Ast_412.Asttypes.closed_flag -> string list option -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_poly : string Location.loc list -> Migrate_parsetree.Ast_412.Parsetree.core_type -> Migrate_parsetree.Ast_412.Parsetree.core_typeval ptyp_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.core_typeval pdir_string : string -> Migrate_parsetree.Ast_412.Parsetree.directive_argumentval pdir_int : string -> char option -> Migrate_parsetree.Ast_412.Parsetree.directive_argumentval pdir_ident : Ocaml_common.Longident.t -> Migrate_parsetree.Ast_412.Parsetree.directive_argumentval pdir_bool : bool -> Migrate_parsetree.Ast_412.Parsetree.directive_argumentval pexp_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_constant : Migrate_parsetree.Ast_412.Parsetree.constant -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_function : Migrate_parsetree.Ast_412.Parsetree.case list -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_tuple : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_construct : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression option -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_variant : string -> Migrate_parsetree.Ast_412.Parsetree.expression option -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_record : (Ocaml_common.Longident.t Location.loc * Migrate_parsetree.Ast_412.Parsetree.expression) list -> Migrate_parsetree.Ast_412.Parsetree.expression option -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_array : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_for : 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 pexp_send : Migrate_parsetree.Ast_412.Parsetree.expression -> string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_setinstvar : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_override : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.expression) list -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_letmodule : string option Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_expr -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_newtype : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.expressionval pexp_unreachable : Migrate_parsetree.Ast_412.Parsetree.expressionval extension_constructor : name:string Location.loc -> kind:Migrate_parsetree.Ast_412.Parsetree.extension_constructor_kind -> Migrate_parsetree.Ast_412.Parsetree.extension_constructorval include_infos : 'a -> 'a Migrate_parsetree.Ast_412.Parsetree.include_infosval label_declaration : name:string Location.loc -> mutable_:Migrate_parsetree.Ast_412.Asttypes.mutable_flag -> type_:Migrate_parsetree.Ast_412.Parsetree.core_type -> Migrate_parsetree.Ast_412.Parsetree.label_declarationval location : start:Lexing.position -> end_:Lexing.position -> ghost:bool -> Warnings.locval module_binding : name:string option Location.loc -> expr:Migrate_parsetree.Ast_412.Parsetree.module_expr -> Migrate_parsetree.Ast_412.Parsetree.module_bindingval module_declaration : name:string option Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.module_type -> Migrate_parsetree.Ast_412.Parsetree.module_declarationval pmod_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_exprval pmod_structure : Migrate_parsetree.Ast_412.Parsetree.structure_item list -> Migrate_parsetree.Ast_412.Parsetree.module_exprval pmod_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.module_exprval module_substitution : name:string Location.loc -> manifest:Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_substitutionval pmty_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_typeval pmty_signature : Migrate_parsetree.Ast_412.Parsetree.signature_item list -> Migrate_parsetree.Ast_412.Parsetree.module_typeval pmty_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.module_typeval pmty_alias : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_typeval module_type_declaration : name:string Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.module_type option -> Migrate_parsetree.Ast_412.Parsetree.module_type_declarationval open_infos : expr:'a -> override:Migrate_parsetree.Ast_412.Asttypes.override_flag -> 'a Migrate_parsetree.Ast_412.Parsetree.open_infosval ppat_any : Migrate_parsetree.Ast_412.Parsetree.patternval ppat_var : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_alias : Migrate_parsetree.Ast_412.Parsetree.pattern -> string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_constant : Migrate_parsetree.Ast_412.Parsetree.constant -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_tuple : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_construct : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern option -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_variant : string -> Migrate_parsetree.Ast_412.Parsetree.pattern option -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_array : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_type : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_unpack : string option Location.loc -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_exception : Migrate_parsetree.Ast_412.Parsetree.pattern -> Migrate_parsetree.Ast_412.Parsetree.patternval ppat_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.patternval position : fname:string -> lnum:int -> bol:int -> cnum:int -> Lexing.positionval rtag : string Location.loc -> bool -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.row_fieldval psig_typesubst : Migrate_parsetree.Ast_412.Parsetree.type_declaration list -> Migrate_parsetree.Ast_412.Parsetree.signature_itemval psig_exception : Migrate_parsetree.Ast_412.Parsetree.type_exception -> Migrate_parsetree.Ast_412.Parsetree.signature_itemval psig_recmodule : Migrate_parsetree.Ast_412.Parsetree.module_declaration list -> Migrate_parsetree.Ast_412.Parsetree.signature_itemval psig_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.signature_itemval psig_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.attribute list -> Migrate_parsetree.Ast_412.Parsetree.signature_itemval pstr_exception : Migrate_parsetree.Ast_412.Parsetree.type_exception -> Migrate_parsetree.Ast_412.Parsetree.structure_itemval pstr_recmodule : Migrate_parsetree.Ast_412.Parsetree.module_binding list -> Migrate_parsetree.Ast_412.Parsetree.structure_itemval pstr_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.structure_itemval pstr_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.attribute list -> Migrate_parsetree.Ast_412.Parsetree.structure_itemval toplevel_directive : name:string Location.loc -> arg:Migrate_parsetree.Ast_412.Parsetree.directive_argument option -> Migrate_parsetree.Ast_412.Parsetree.toplevel_directiveval type_declaration : 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 : path:Ocaml_common.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 value_binding : pat:Migrate_parsetree.Ast_412.Parsetree.pattern -> expr:Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.value_bindingval value_description : name:string Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.core_type -> prim:string list -> Migrate_parsetree.Ast_412.Parsetree.value_descriptionval eint : int -> Migrate_parsetree.Ast_412.Parsetree.expressionval echar : char -> Migrate_parsetree.Ast_412.Parsetree.expressionval estring : string -> Migrate_parsetree.Ast_412.Parsetree.expressionval efloat : string -> Migrate_parsetree.Ast_412.Parsetree.expressionval eint32 : int32 -> Migrate_parsetree.Ast_412.Parsetree.expressionval eint64 : int64 -> Migrate_parsetree.Ast_412.Parsetree.expressionval enativeint : nativeint -> Migrate_parsetree.Ast_412.Parsetree.expressionval ebool : bool -> Migrate_parsetree.Ast_412.Parsetree.expressionval pint : int -> Migrate_parsetree.Ast_412.Parsetree.patternval pchar : char -> Migrate_parsetree.Ast_412.Parsetree.patternval pstring : string -> Migrate_parsetree.Ast_412.Parsetree.patternval pfloat : string -> Migrate_parsetree.Ast_412.Parsetree.patternval pint32 : int32 -> Migrate_parsetree.Ast_412.Parsetree.patternval pint64 : int64 -> Migrate_parsetree.Ast_412.Parsetree.patternval pnativeint : nativeint -> Migrate_parsetree.Ast_412.Parsetree.patternval pbool : bool -> Migrate_parsetree.Ast_412.Parsetree.patternval eunit : Migrate_parsetree.Ast_412.Parsetree.expressionval punit : Migrate_parsetree.Ast_412.Parsetree.patternval evar : 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 : string -> Migrate_parsetree.Ast_412.Parsetree.patternval eapply : 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 esequence : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expressionval ppat_tuple_opt : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.pattern optionval pexp_tuple_opt : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression optionval pstr_value_list : loc:Location.t -> Ppxlib_ast.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 : name:string Loc.t -> params:(Migrate_parsetree.Ast_412.Parsetree.core_type * Ppxlib_ast.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_ast.Asttypes.private_flag -> manifest:Migrate_parsetree.Ast_412.Parsetree.core_type option -> Migrate_parsetree.Ast_412.Parsetree.type_declarationval unapplied_type_constr_conv : 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 : 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.
val eta_reduce_if_possible : Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expressionval eta_reduce_if_possible_and_nonrec : Migrate_parsetree.Ast_412.Parsetree.expression -> rec_flag:Migrate_parsetree.Ast_412.Asttypes.rec_flag -> Migrate_parsetree.Ast_412.Parsetree.expression