package ppxlib
Module Ast_builder.Make
Build Ast helpers with the location argument factorized.
Parameters
Signature
module Located : sig ... endinclude sig ... end
val loc : Location.tval attribute :
name:string Location.loc ->
payload:Migrate_parsetree.Ast_411.Parsetree.payload ->
Migrate_parsetree.Ast_411.Parsetree.attributeval binding_op :
op:string Location.loc ->
pat:Migrate_parsetree.Ast_411.Parsetree.pattern ->
exp:Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.binding_opval case :
lhs:Migrate_parsetree.Ast_411.Parsetree.pattern ->
guard:Migrate_parsetree.Ast_411.Parsetree.expression option ->
rhs:Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.caseval pcl_constr :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.class_exprval pcl_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.class_exprval pcl_open :
Ppxlib_ast__.Import.Longident.t Location.loc
Migrate_parsetree.Ast_411.Parsetree.open_infos ->
Migrate_parsetree.Ast_411.Parsetree.class_expr ->
Migrate_parsetree.Ast_411.Parsetree.class_exprval pcf_inherit :
Migrate_parsetree.Ast_411.Asttypes.override_flag ->
Migrate_parsetree.Ast_411.Parsetree.class_expr ->
string Location.loc option ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval pcf_val :
(string Location.loc
* Migrate_parsetree.Ast_411.Asttypes.mutable_flag
* Migrate_parsetree.Ast_411.Parsetree.class_field_kind) ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval pcf_method :
(string Location.loc
* Migrate_parsetree.Ast_411.Asttypes.private_flag
* Migrate_parsetree.Ast_411.Parsetree.class_field_kind) ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval pcf_initializer :
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval pcf_attribute :
Migrate_parsetree.Ast_411.Parsetree.attribute ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval pcf_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.class_fieldval class_infos :
virt:Migrate_parsetree.Ast_411.Asttypes.virtual_flag ->
params:
(Migrate_parsetree.Ast_411.Parsetree.core_type
* Migrate_parsetree.Ast_411.Asttypes.variance)
list ->
name:string Location.loc ->
expr:'a ->
'a Migrate_parsetree.Ast_411.Parsetree.class_infosval class_signature :
self:Migrate_parsetree.Ast_411.Parsetree.core_type ->
fields:Migrate_parsetree.Ast_411.Parsetree.class_type_field list ->
Migrate_parsetree.Ast_411.Parsetree.class_signatureval class_structure :
self:Migrate_parsetree.Ast_411.Parsetree.pattern ->
fields:Migrate_parsetree.Ast_411.Parsetree.class_field list ->
Migrate_parsetree.Ast_411.Parsetree.class_structureval pcty_constr :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.class_typeval pcty_signature :
Migrate_parsetree.Ast_411.Parsetree.class_signature ->
Migrate_parsetree.Ast_411.Parsetree.class_typeval pcty_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.class_typeval pcty_open :
Ppxlib_ast__.Import.Longident.t Location.loc
Migrate_parsetree.Ast_411.Parsetree.open_infos ->
Migrate_parsetree.Ast_411.Parsetree.class_type ->
Migrate_parsetree.Ast_411.Parsetree.class_typeval pctf_val :
(string Location.loc
* Migrate_parsetree.Ast_411.Asttypes.mutable_flag
* Migrate_parsetree.Ast_411.Asttypes.virtual_flag
* Migrate_parsetree.Ast_411.Parsetree.core_type) ->
Migrate_parsetree.Ast_411.Parsetree.class_type_fieldval pctf_method :
(string Location.loc
* Migrate_parsetree.Ast_411.Asttypes.private_flag
* Migrate_parsetree.Ast_411.Asttypes.virtual_flag
* Migrate_parsetree.Ast_411.Parsetree.core_type) ->
Migrate_parsetree.Ast_411.Parsetree.class_type_fieldval pctf_attribute :
Migrate_parsetree.Ast_411.Parsetree.attribute ->
Migrate_parsetree.Ast_411.Parsetree.class_type_fieldval pctf_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.class_type_fieldval constructor_declaration :
name:string Location.loc ->
args:Migrate_parsetree.Ast_411.Parsetree.constructor_arguments ->
res:Migrate_parsetree.Ast_411.Parsetree.core_type option ->
Migrate_parsetree.Ast_411.Parsetree.constructor_declarationval ptyp_any : Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_var : string -> Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_tuple :
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_constr :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_class :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_alias :
Migrate_parsetree.Ast_411.Parsetree.core_type ->
string ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_variant :
Migrate_parsetree.Ast_411.Parsetree.row_field list ->
Migrate_parsetree.Ast_411.Asttypes.closed_flag ->
string list option ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_poly :
string Location.loc list ->
Migrate_parsetree.Ast_411.Parsetree.core_type ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_package :
(Ppxlib_ast__.Import.Longident.t Location.loc
* (Ppxlib_ast__.Import.Longident.t Location.loc
* Migrate_parsetree.Ast_411.Parsetree.core_type)
list) ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval ptyp_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.core_typeval pdir_string :
string ->
Migrate_parsetree.Ast_411.Parsetree.directive_argumentval pdir_int :
string ->
char option ->
Migrate_parsetree.Ast_411.Parsetree.directive_argumentval pdir_ident :
Ppxlib_ast__.Import.Longident.t ->
Migrate_parsetree.Ast_411.Parsetree.directive_argumentval pdir_bool : bool -> Migrate_parsetree.Ast_411.Parsetree.directive_argumentval pexp_ident :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_constant :
Migrate_parsetree.Ast_411.Parsetree.constant ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_function :
Migrate_parsetree.Ast_411.Parsetree.case list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_tuple :
Migrate_parsetree.Ast_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_construct :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expression option ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_variant :
string ->
Migrate_parsetree.Ast_411.Parsetree.expression option ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_record :
(Ppxlib_ast__.Import.Longident.t Location.loc
* Migrate_parsetree.Ast_411.Parsetree.expression)
list ->
Migrate_parsetree.Ast_411.Parsetree.expression option ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_field :
Migrate_parsetree.Ast_411.Parsetree.expression ->
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_setfield :
Migrate_parsetree.Ast_411.Parsetree.expression ->
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_array :
Migrate_parsetree.Ast_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_for :
Migrate_parsetree.Ast_411.Parsetree.pattern ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Asttypes.direction_flag ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_send :
Migrate_parsetree.Ast_411.Parsetree.expression ->
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_new :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_setinstvar :
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_override :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.expression) list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_letmodule :
string option Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.module_expr ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_newtype :
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.expressionval pexp_unreachable : Migrate_parsetree.Ast_411.Parsetree.expressionval extension_constructor :
name:string Location.loc ->
kind:Migrate_parsetree.Ast_411.Parsetree.extension_constructor_kind ->
Migrate_parsetree.Ast_411.Parsetree.extension_constructorval include_infos : 'a -> 'a Migrate_parsetree.Ast_411.Parsetree.include_infosval label_declaration :
name:string Location.loc ->
mutable_:Migrate_parsetree.Ast_411.Asttypes.mutable_flag ->
type_:Migrate_parsetree.Ast_411.Parsetree.core_type ->
Migrate_parsetree.Ast_411.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_411.Parsetree.module_expr ->
Migrate_parsetree.Ast_411.Parsetree.module_bindingval module_declaration :
name:string option Location.loc ->
type_:Migrate_parsetree.Ast_411.Parsetree.module_type ->
Migrate_parsetree.Ast_411.Parsetree.module_declarationval pmod_ident :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.module_exprval pmod_structure :
Migrate_parsetree.Ast_411.Parsetree.structure_item list ->
Migrate_parsetree.Ast_411.Parsetree.module_exprval pmod_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.module_exprval module_substitution :
name:string Location.loc ->
manifest:Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.module_substitutionval pmty_ident :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.module_typeval pmty_signature :
Migrate_parsetree.Ast_411.Parsetree.signature_item list ->
Migrate_parsetree.Ast_411.Parsetree.module_typeval pmty_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.module_typeval pmty_alias :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.module_typeval module_type_declaration :
name:string Location.loc ->
type_:Migrate_parsetree.Ast_411.Parsetree.module_type option ->
Migrate_parsetree.Ast_411.Parsetree.module_type_declarationval otag :
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.core_type ->
Migrate_parsetree.Ast_411.Parsetree.object_fieldval open_infos :
expr:'a ->
override:Migrate_parsetree.Ast_411.Asttypes.override_flag ->
'a Migrate_parsetree.Ast_411.Parsetree.open_infosval ppat_any : Migrate_parsetree.Ast_411.Parsetree.patternval ppat_var :
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_alias :
Migrate_parsetree.Ast_411.Parsetree.pattern ->
string Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_constant :
Migrate_parsetree.Ast_411.Parsetree.constant ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_tuple :
Migrate_parsetree.Ast_411.Parsetree.pattern list ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_construct :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.pattern option ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_variant :
string ->
Migrate_parsetree.Ast_411.Parsetree.pattern option ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_record :
(Ppxlib_ast__.Import.Longident.t Location.loc
* Migrate_parsetree.Ast_411.Parsetree.pattern)
list ->
Migrate_parsetree.Ast_411.Asttypes.closed_flag ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_array :
Migrate_parsetree.Ast_411.Parsetree.pattern list ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_type :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_unpack :
string option Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_exception :
Migrate_parsetree.Ast_411.Parsetree.pattern ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.patternval ppat_open :
Ppxlib_ast__.Import.Longident.t Location.loc ->
Migrate_parsetree.Ast_411.Parsetree.pattern ->
Migrate_parsetree.Ast_411.Parsetree.patternval position :
fname:string ->
lnum:int ->
bol:int ->
cnum:int ->
Lexing.positionval rtag :
string Location.loc ->
bool ->
Migrate_parsetree.Ast_411.Parsetree.core_type list ->
Migrate_parsetree.Ast_411.Parsetree.row_fieldval psig_typesubst :
Migrate_parsetree.Ast_411.Parsetree.type_declaration list ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval psig_exception :
Migrate_parsetree.Ast_411.Parsetree.type_exception ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval psig_recmodule :
Migrate_parsetree.Ast_411.Parsetree.module_declaration list ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval psig_open :
Ppxlib_ast__.Import.Longident.t Location.loc
Migrate_parsetree.Ast_411.Parsetree.open_infos ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval psig_attribute :
Migrate_parsetree.Ast_411.Parsetree.attribute ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval psig_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.attribute list ->
Migrate_parsetree.Ast_411.Parsetree.signature_itemval pstr_exception :
Migrate_parsetree.Ast_411.Parsetree.type_exception ->
Migrate_parsetree.Ast_411.Parsetree.structure_itemval pstr_recmodule :
Migrate_parsetree.Ast_411.Parsetree.module_binding list ->
Migrate_parsetree.Ast_411.Parsetree.structure_itemval pstr_attribute :
Migrate_parsetree.Ast_411.Parsetree.attribute ->
Migrate_parsetree.Ast_411.Parsetree.structure_itemval pstr_extension :
(string Location.loc * Migrate_parsetree.Ast_411.Parsetree.payload) ->
Migrate_parsetree.Ast_411.Parsetree.attribute list ->
Migrate_parsetree.Ast_411.Parsetree.structure_itemval toplevel_directive :
name:string Location.loc ->
arg:Migrate_parsetree.Ast_411.Parsetree.directive_argument option ->
Migrate_parsetree.Ast_411.Parsetree.toplevel_directiveval type_declaration :
name:string Location.loc ->
params:
(Migrate_parsetree.Ast_411.Parsetree.core_type
* Migrate_parsetree.Ast_411.Asttypes.variance)
list ->
cstrs:
(Migrate_parsetree.Ast_411.Parsetree.core_type
* Migrate_parsetree.Ast_411.Parsetree.core_type
* Warnings.loc)
list ->
kind:Migrate_parsetree.Ast_411.Parsetree.type_kind ->
private_:Migrate_parsetree.Ast_411.Asttypes.private_flag ->
manifest:Migrate_parsetree.Ast_411.Parsetree.core_type option ->
Migrate_parsetree.Ast_411.Parsetree.type_declarationval type_extension :
path:Ppxlib_ast__.Import.Longident.t Location.loc ->
params:
(Migrate_parsetree.Ast_411.Parsetree.core_type
* Migrate_parsetree.Ast_411.Asttypes.variance)
list ->
constructors:Migrate_parsetree.Ast_411.Parsetree.extension_constructor list ->
private_:Migrate_parsetree.Ast_411.Asttypes.private_flag ->
Migrate_parsetree.Ast_411.Parsetree.type_extensionval value_binding :
pat:Migrate_parsetree.Ast_411.Parsetree.pattern ->
expr:Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.value_bindingval value_description :
name:string Location.loc ->
type_:Migrate_parsetree.Ast_411.Parsetree.core_type ->
prim:string list ->
Migrate_parsetree.Ast_411.Parsetree.value_descriptionval eint : int -> Migrate_parsetree.Ast_411.Parsetree.expressionval echar : char -> Migrate_parsetree.Ast_411.Parsetree.expressionval estring : string -> Migrate_parsetree.Ast_411.Parsetree.expressionval efloat : string -> Migrate_parsetree.Ast_411.Parsetree.expressionval eint32 : int32 -> Migrate_parsetree.Ast_411.Parsetree.expressionval eint64 : int64 -> Migrate_parsetree.Ast_411.Parsetree.expressionval enativeint : nativeint -> Migrate_parsetree.Ast_411.Parsetree.expressionval ebool : bool -> Migrate_parsetree.Ast_411.Parsetree.expressionval pint : int -> Migrate_parsetree.Ast_411.Parsetree.patternval pchar : char -> Migrate_parsetree.Ast_411.Parsetree.patternval pstring : string -> Migrate_parsetree.Ast_411.Parsetree.patternval pfloat : string -> Migrate_parsetree.Ast_411.Parsetree.patternval pint32 : int32 -> Migrate_parsetree.Ast_411.Parsetree.patternval pint64 : int64 -> Migrate_parsetree.Ast_411.Parsetree.patternval pnativeint : nativeint -> Migrate_parsetree.Ast_411.Parsetree.patternval pbool : bool -> Migrate_parsetree.Ast_411.Parsetree.patternval eunit : Migrate_parsetree.Ast_411.Parsetree.expressionval punit : Migrate_parsetree.Ast_411.Parsetree.patternval evar : string -> Migrate_parsetree.Ast_411.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_411.Parsetree.patternval eapply :
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expressionSame as pexp_apply but without labels
val esequence :
Migrate_parsetree.Ast_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval ppat_tuple_opt :
Migrate_parsetree.Ast_411.Parsetree.pattern list ->
Migrate_parsetree.Ast_411.Parsetree.pattern optionval pexp_tuple_opt :
Migrate_parsetree.Ast_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expression optionval pstr_value_list :
loc:Location.t ->
Ppxlib_ast.Asttypes.rec_flag ->
Migrate_parsetree.Ast_411.Parsetree.value_binding list ->
Migrate_parsetree.Ast_411.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_411.Parsetree.core_type
* Ppxlib_ast.Asttypes.variance)
list ->
cstrs:
(Migrate_parsetree.Ast_411.Parsetree.core_type
* Migrate_parsetree.Ast_411.Parsetree.core_type
* Location.t)
list ->
kind:Migrate_parsetree.Ast_411.Parsetree.type_kind ->
private_:Ppxlib_ast.Asttypes.private_flag ->
manifest:Migrate_parsetree.Ast_411.Parsetree.core_type option ->
Migrate_parsetree.Ast_411.Parsetree.type_declarationval unapplied_type_constr_conv :
Longident.t Loc.t ->
f:(string -> string) ->
Migrate_parsetree.Ast_411.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:
- sexp_of_t if path is "t"
- A.B.sexp_of_foo if path is "A.B.foo"
- A.B.sexp_of_f__foo (module A1) (module A2) if path is "A.B.F(A1)(A2).foo"
type_constr_convalso 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_411.Parsetree.expression list ->
Migrate_parsetree.Ast_411.Parsetree.expressionval eta_reduce :
Migrate_parsetree.Ast_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.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:
- if
fhas optional arguments, eta-expandingfcan drop them - because labels commute, it can change the type of an expression: $ let f ~x y = x + y let f2 = fun x -> add x;; val f : x:int -> int -> int = <fun> val f2 : int -> x:int -> int = <fun> In fact, if
fdoes 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_411.Parsetree.expression ->
Migrate_parsetree.Ast_411.Parsetree.expressionval eta_reduce_if_possible_and_nonrec :
Migrate_parsetree.Ast_411.Parsetree.expression ->
rec_flag:Migrate_parsetree.Ast_411.Asttypes.rec_flag ->
Migrate_parsetree.Ast_411.Parsetree.expression