Ast_builder.Make
Build Ast helpers with the location argument factorized.
module Located : sig ... end
val loc : Location.t
val attribute : name:string Location.loc -> payload:Migrate_parsetree.Ast_412.Parsetree.payload -> Migrate_parsetree.Ast_412.Parsetree.attribute
val 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_op
val 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.case
val pcl_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_expr
val 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_field
val pcf_initializer : Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.class_field
val pcf_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.class_field
val pcf_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_field
val 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_infos
val 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_signature
val class_structure : self:Migrate_parsetree.Ast_412.Parsetree.pattern -> fields:Migrate_parsetree.Ast_412.Parsetree.class_field list -> Migrate_parsetree.Ast_412.Parsetree.class_structure
val pcty_constr : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.class_type
val pcty_signature : Migrate_parsetree.Ast_412.Parsetree.class_signature -> Migrate_parsetree.Ast_412.Parsetree.class_type
val pcty_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_type
val pctf_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.class_type_field
val pctf_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.class_type_field
val 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_declaration
val ptyp_any : Migrate_parsetree.Ast_412.Parsetree.core_type
val ptyp_var : string -> Migrate_parsetree.Ast_412.Parsetree.core_type
val ptyp_tuple : Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.core_type
val ptyp_constr : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.core_type
val ptyp_alias : Migrate_parsetree.Ast_412.Parsetree.core_type -> string -> Migrate_parsetree.Ast_412.Parsetree.core_type
val 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_type
val ptyp_poly : string Location.loc list -> Migrate_parsetree.Ast_412.Parsetree.core_type -> Migrate_parsetree.Ast_412.Parsetree.core_type
val ptyp_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.core_type
val pdir_string : string -> Migrate_parsetree.Ast_412.Parsetree.directive_argument
val pdir_int : string -> char option -> Migrate_parsetree.Ast_412.Parsetree.directive_argument
val pdir_ident : Ocaml_common.Longident.t -> Migrate_parsetree.Ast_412.Parsetree.directive_argument
val pdir_bool : bool -> Migrate_parsetree.Ast_412.Parsetree.directive_argument
val pexp_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_constant : Migrate_parsetree.Ast_412.Parsetree.constant -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_function : Migrate_parsetree.Ast_412.Parsetree.case list -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_tuple : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_construct : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression option -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_variant : string -> Migrate_parsetree.Ast_412.Parsetree.expression option -> Migrate_parsetree.Ast_412.Parsetree.expression
val 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.expression
val pexp_array : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression
val 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.expression
val pexp_send : Migrate_parsetree.Ast_412.Parsetree.expression -> string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_setinstvar : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_override : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.expression) list -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_letmodule : string option Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_expr -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_newtype : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.expression
val pexp_unreachable : Migrate_parsetree.Ast_412.Parsetree.expression
val extension_constructor : name:string Location.loc -> kind:Migrate_parsetree.Ast_412.Parsetree.extension_constructor_kind -> Migrate_parsetree.Ast_412.Parsetree.extension_constructor
val include_infos : 'a -> 'a Migrate_parsetree.Ast_412.Parsetree.include_infos
val 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_declaration
val location : start:Lexing.position -> end_:Lexing.position -> ghost:bool -> Warnings.loc
val module_binding : name:string option Location.loc -> expr:Migrate_parsetree.Ast_412.Parsetree.module_expr -> Migrate_parsetree.Ast_412.Parsetree.module_binding
val module_declaration : name:string option Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.module_type -> Migrate_parsetree.Ast_412.Parsetree.module_declaration
val pmod_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_expr
val pmod_structure : Migrate_parsetree.Ast_412.Parsetree.structure_item list -> Migrate_parsetree.Ast_412.Parsetree.module_expr
val pmod_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.module_expr
val module_substitution : name:string Location.loc -> manifest:Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_substitution
val pmty_ident : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_type
val pmty_signature : Migrate_parsetree.Ast_412.Parsetree.signature_item list -> Migrate_parsetree.Ast_412.Parsetree.module_type
val pmty_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.module_type
val pmty_alias : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.module_type
val module_type_declaration : name:string Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.module_type option -> Migrate_parsetree.Ast_412.Parsetree.module_type_declaration
val open_infos : expr:'a -> override:Migrate_parsetree.Ast_412.Asttypes.override_flag -> 'a Migrate_parsetree.Ast_412.Parsetree.open_infos
val ppat_any : Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_var : string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_alias : Migrate_parsetree.Ast_412.Parsetree.pattern -> string Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_constant : Migrate_parsetree.Ast_412.Parsetree.constant -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_tuple : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_construct : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern option -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_variant : string -> Migrate_parsetree.Ast_412.Parsetree.pattern option -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_array : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_type : Ocaml_common.Longident.t Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_unpack : string option Location.loc -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_exception : Migrate_parsetree.Ast_412.Parsetree.pattern -> Migrate_parsetree.Ast_412.Parsetree.pattern
val ppat_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.pattern
val position : fname:string -> lnum:int -> bol:int -> cnum:int -> Lexing.position
val rtag : string Location.loc -> bool -> Migrate_parsetree.Ast_412.Parsetree.core_type list -> Migrate_parsetree.Ast_412.Parsetree.row_field
val psig_typesubst : Migrate_parsetree.Ast_412.Parsetree.type_declaration list -> Migrate_parsetree.Ast_412.Parsetree.signature_item
val psig_exception : Migrate_parsetree.Ast_412.Parsetree.type_exception -> Migrate_parsetree.Ast_412.Parsetree.signature_item
val psig_recmodule : Migrate_parsetree.Ast_412.Parsetree.module_declaration list -> Migrate_parsetree.Ast_412.Parsetree.signature_item
val psig_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.signature_item
val psig_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.attribute list -> Migrate_parsetree.Ast_412.Parsetree.signature_item
val pstr_exception : Migrate_parsetree.Ast_412.Parsetree.type_exception -> Migrate_parsetree.Ast_412.Parsetree.structure_item
val pstr_recmodule : Migrate_parsetree.Ast_412.Parsetree.module_binding list -> Migrate_parsetree.Ast_412.Parsetree.structure_item
val pstr_attribute : Migrate_parsetree.Ast_412.Parsetree.attribute -> Migrate_parsetree.Ast_412.Parsetree.structure_item
val pstr_extension : (string Location.loc * Migrate_parsetree.Ast_412.Parsetree.payload) -> Migrate_parsetree.Ast_412.Parsetree.attribute list -> Migrate_parsetree.Ast_412.Parsetree.structure_item
val toplevel_directive : name:string Location.loc -> arg:Migrate_parsetree.Ast_412.Parsetree.directive_argument option -> Migrate_parsetree.Ast_412.Parsetree.toplevel_directive
val 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_declaration
val 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_extension
val value_binding : pat:Migrate_parsetree.Ast_412.Parsetree.pattern -> expr:Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.value_binding
val value_description : name:string Location.loc -> type_:Migrate_parsetree.Ast_412.Parsetree.core_type -> prim:string list -> Migrate_parsetree.Ast_412.Parsetree.value_description
val eint : int -> Migrate_parsetree.Ast_412.Parsetree.expression
val echar : char -> Migrate_parsetree.Ast_412.Parsetree.expression
val estring : string -> Migrate_parsetree.Ast_412.Parsetree.expression
val efloat : string -> Migrate_parsetree.Ast_412.Parsetree.expression
val eint32 : int32 -> Migrate_parsetree.Ast_412.Parsetree.expression
val eint64 : int64 -> Migrate_parsetree.Ast_412.Parsetree.expression
val enativeint : nativeint -> Migrate_parsetree.Ast_412.Parsetree.expression
val ebool : bool -> Migrate_parsetree.Ast_412.Parsetree.expression
val pint : int -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pchar : char -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pstring : string -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pfloat : string -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pint32 : int32 -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pint64 : int64 -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pnativeint : nativeint -> Migrate_parsetree.Ast_412.Parsetree.pattern
val pbool : bool -> Migrate_parsetree.Ast_412.Parsetree.pattern
val eunit : Migrate_parsetree.Ast_412.Parsetree.expression
val punit : Migrate_parsetree.Ast_412.Parsetree.pattern
val evar : string -> Migrate_parsetree.Ast_412.Parsetree.expression
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 : string -> Migrate_parsetree.Ast_412.Parsetree.pattern
val eapply : Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression
Same as pexp_apply but without labels
val esequence : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression
val ppat_tuple_opt : Migrate_parsetree.Ast_412.Parsetree.pattern list -> Migrate_parsetree.Ast_412.Parsetree.pattern option
val pexp_tuple_opt : Migrate_parsetree.Ast_412.Parsetree.expression list -> Migrate_parsetree.Ast_412.Parsetree.expression option
val 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 list
pstr_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_declaration
val unapplied_type_constr_conv : Longident.t Loc.t -> f:(string -> string) -> Migrate_parsetree.Ast_412.Parsetree.expression
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:
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.expression
val eta_reduce : Migrate_parsetree.Ast_412.Parsetree.expression -> Migrate_parsetree.Ast_412.Parsetree.expression 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:
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.expression
val 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