Ast_builder.DefaultHelpers taking a ~loc argument. This module is meant to be opened or aliased.
module Located : sig ... endval value_description :
loc:Location.t ->
name:string Astlib.Location.loc ->
type_:Astlib.Ast_502.Parsetree.core_type ->
prim:string list ->
Astlib.Ast_502.Parsetree.value_descriptionvalue_description constructs an Ast.value_description
Example OCaml
Values of type value_description represents:
val type_extension :
loc:Location.t ->
path:Astlib.Longident.t Astlib.Location.loc ->
params:
(Astlib.Ast_502.Parsetree.core_type
* (Astlib.Ast_502.Asttypes.variance * Astlib.Ast_502.Asttypes.injectivity))
list ->
constructors:Astlib.Ast_502.Parsetree.extension_constructor list ->
private_:Astlib.Ast_502.Asttypes.private_flag ->
Astlib.Ast_502.Parsetree.type_extensiontype_extension constructs an Ast.type_extension
Example OCaml
Definition of new extensions constructors for the extensive sum type t (type t += ...).
val type_exception :
loc:Location.t ->
Astlib.Ast_502.Parsetree.extension_constructor ->
Astlib.Ast_502.Parsetree.type_exceptiontype_exception constructs an Ast.type_exception
Example OCaml
Definition of a new exception (exception E).
val type_declaration :
loc:Location.t ->
name:string Astlib.Location.loc ->
params:
(Astlib.Ast_502.Parsetree.core_type
* (Astlib.Ast_502.Asttypes.variance * Astlib.Ast_502.Asttypes.injectivity))
list ->
cstrs:
(Astlib.Ast_502.Parsetree.core_type
* Astlib.Ast_502.Parsetree.core_type
* Astlib.Location.t)
list ->
kind:Astlib.Ast_502.Parsetree.type_kind ->
private_:Astlib.Ast_502.Asttypes.private_flag ->
manifest:Astlib.Ast_502.Parsetree.core_type option ->
Astlib.Ast_502.Parsetree.type_declarationtype_declaration constructs an Ast.type_declaration
Example OCaml
Here are type declarations and their representation, for various ptype_kind and ptype_manifest values:
type t when type_kind is Ptype_abstract, and manifest is None,type t = T0 when type_kind is Ptype_abstract, and manifest is Some T0,type t = C of T | ... when type_kind is Ptype_variant, and manifest is None,type t = T0 = C of T | ... when type_kind is Ptype_variant, and manifest is Some T0,type t = {l: T; ...} when type_kind is Ptype_record, and manifest is None,type t = T0 = {l : T; ...} when type_kind is Ptype_record, and manifest is Some T0,type t = .. when type_kind is Ptype_open, and manifest is None.val toplevel_directive :
loc:Location.t ->
name:string Astlib.Location.loc ->
arg:Astlib.Ast_502.Parsetree.directive_argument option ->
Astlib.Ast_502.Parsetree.toplevel_directivetoplevel_directive constructs an Ast.toplevel_directive
val pstr_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.attribute list ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_attribute :
loc:Location.t ->
Astlib.Ast_502.Parsetree.attribute ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_include :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr Astlib.Ast_502.Parsetree.include_infos ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_class_type :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_type Astlib.Ast_502.Parsetree.class_infos list ->
Astlib.Ast_502.Parsetree.structure_itempstr_class_type constructs an Ast.structure_item_desc.Pstr_class_type
Example OCaml
class type ct1 = ... and ... and ctn = ...
val pstr_class :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_expr Astlib.Ast_502.Parsetree.class_infos list ->
Astlib.Ast_502.Parsetree.structure_itempstr_class constructs an Ast.structure_item_desc.Pstr_class
Example OCaml
class c1 = ... and ... and cn = ...
val pstr_modtype :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_type_declaration ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_recmodule :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_binding list ->
Astlib.Ast_502.Parsetree.structure_itempstr_recmodule constructs an Ast.structure_item_desc.Pstr_recmodule
Example OCaml
module rec X1 = ME1 and ... and Xn = MEn
val pstr_module :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_binding ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_exception :
loc:Location.t ->
Astlib.Ast_502.Parsetree.type_exception ->
Astlib.Ast_502.Parsetree.structure_itempstr_exception constructs an Ast.structure_item_desc.Pstr_exception
Example OCaml
exception C of Texception C = M.Xval pstr_typext :
loc:Location.t ->
Astlib.Ast_502.Parsetree.type_extension ->
Astlib.Ast_502.Parsetree.structure_itemval pstr_type :
loc:Location.t ->
Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.type_declaration list ->
Astlib.Ast_502.Parsetree.structure_itempstr_type constructs an Ast.structure_item_desc.Pstr_type
Example OCaml
type t1 = ... and ... and tn = ...
val pstr_primitive :
loc:Location.t ->
Astlib.Ast_502.Parsetree.value_description ->
Astlib.Ast_502.Parsetree.structure_itempstr_primitive constructs an Ast.structure_item_desc.Pstr_primitive
Example OCaml
val x: Texternal x: T = "s1" ... "sn" val pstr_value :
loc:Location.t ->
Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.value_binding list ->
Astlib.Ast_502.Parsetree.structure_itempstr_value constructs an Ast.structure_item_desc.Pstr_value
Example OCaml
Pstr_value(rec, [(P1, E1 ; ... ; (Pn, En))]) represents:
let P1 = E1 and ... and Pn = EN when rec is Nonrecursive,let rec P1 = E1 and ... and Pn = EN when rec is Recursive.val pstr_eval :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.attribute list ->
Astlib.Ast_502.Parsetree.structure_itemval psig_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.attribute list ->
Astlib.Ast_502.Parsetree.signature_itemval psig_attribute :
loc:Location.t ->
Astlib.Ast_502.Parsetree.attribute ->
Astlib.Ast_502.Parsetree.signature_itemval psig_class_type :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_type Astlib.Ast_502.Parsetree.class_infos list ->
Astlib.Ast_502.Parsetree.signature_itempsig_class_type constructs an Ast.signature_item_desc.Psig_class_type
Example OCaml
class type ct1 = ... and ... and ctn = ...
val psig_class :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_type Astlib.Ast_502.Parsetree.class_infos list ->
Astlib.Ast_502.Parsetree.signature_itempsig_class constructs an Ast.signature_item_desc.Psig_class
Example OCaml
class c1 : ... and ... and cn : ...
val psig_include :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_type Astlib.Ast_502.Parsetree.include_infos ->
Astlib.Ast_502.Parsetree.signature_itemval psig_modtypesubst :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_type_declaration ->
Astlib.Ast_502.Parsetree.signature_itempsig_modtypesubst constructs an Ast.signature_item_desc.Psig_modtypesubst
Example OCaml
module type S := ...
val psig_modtype :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_type_declaration ->
Astlib.Ast_502.Parsetree.signature_itempsig_modtype constructs an Ast.signature_item_desc.Psig_modtype
Example OCaml
module type S = MT and module type S
val psig_recmodule :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_declaration list ->
Astlib.Ast_502.Parsetree.signature_itempsig_recmodule constructs an Ast.signature_item_desc.Psig_recmodule
Example OCaml
module rec X1 : MT1 and ... and Xn : MTn
val psig_modsubst :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_substitution ->
Astlib.Ast_502.Parsetree.signature_itemval psig_module :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_declaration ->
Astlib.Ast_502.Parsetree.signature_itempsig_module constructs an Ast.signature_item_desc.Psig_module
Example OCaml
module X = M and module X : MT
val psig_exception :
loc:Location.t ->
Astlib.Ast_502.Parsetree.type_exception ->
Astlib.Ast_502.Parsetree.signature_itemval psig_typext :
loc:Location.t ->
Astlib.Ast_502.Parsetree.type_extension ->
Astlib.Ast_502.Parsetree.signature_itemval psig_typesubst :
loc:Location.t ->
Astlib.Ast_502.Parsetree.type_declaration list ->
Astlib.Ast_502.Parsetree.signature_itempsig_typesubst constructs an Ast.signature_item_desc.Psig_typesubst
Example OCaml
type t1 := ... and ... and tn := ...
val psig_type :
loc:Location.t ->
Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.type_declaration list ->
Astlib.Ast_502.Parsetree.signature_itempsig_type constructs an Ast.signature_item_desc.Psig_type
Example OCaml
type t1 = ... and ... and tn = ...
val psig_value :
loc:Location.t ->
Astlib.Ast_502.Parsetree.value_description ->
Astlib.Ast_502.Parsetree.signature_itempsig_value constructs an Ast.signature_item_desc.Psig_value
Example OCaml
val x: Texternal x: T = "s1" ... "sn"val rinherit :
loc:Location.t ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.row_fieldval rtag :
loc:Location.t ->
string Astlib.Location.loc ->
bool ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.row_fieldrtag constructs an Ast.row_field_desc.Rtag
Example OCaml
Rtag(`A, b, l) represents:
`A when b is true and l is [],`A of T when b is false and l is [T],`A of T1 & .. & Tn when b is false and l is [T1;...Tn],`A of & T1 & .. & Tn when b is true and l is [T1;...Tn].bool field is true if the tag contains a constant (empty) constructor.& occurs when several types are used for the same constructor (see 4.2 in the manual)position constructs an Ast.position
val ppat_open :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.patternval ppat_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.patternval ppat_exception :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.patternval ppat_unpack :
loc:Location.t ->
string option Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.patternppat_unpack constructs an Ast.pattern_desc.Ppat_unpack
Example OCaml
Ppat_unpack(s) represents:
(module P) when s is Some "P"(module _) when s is NoneNote: (module P : S) is represented as Ppat_constraint(Ppat_unpack(Some "P"), Ptyp_package S)
val ppat_lazy :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.patternval ppat_type :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.patternval ppat_constraint :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.patternval ppat_or :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.patternval ppat_array :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.patternval ppat_record :
loc:Location.t ->
(Astlib.Longident.t Astlib.Location.loc * Astlib.Ast_502.Parsetree.pattern)
list ->
Astlib.Ast_502.Asttypes.closed_flag ->
Astlib.Ast_502.Parsetree.patternppat_record constructs an Ast.pattern_desc.Ppat_record
Example OCaml
Ppat_record([(l1, P1) ; ... ; (ln, Pn)], flag) represents:
Invariant: n > 0
val ppat_variant :
loc:Location.t ->
string ->
Astlib.Ast_502.Parsetree.pattern option ->
Astlib.Ast_502.Parsetree.patternppat_variant constructs an Ast.pattern_desc.Ppat_variant
Example OCaml
Ppat_variant(`A, pat) represents:
`A when pat is None,`A P when pat is Some Pval ppat_tuple :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.patternppat_tuple constructs an Ast.pattern_desc.Ppat_tuple
Example OCaml
Patterns (P1, ..., Pn).
Invariant: n >= 2
val ppat_interval :
loc:Location.t ->
Astlib.Ast_502.Parsetree.constant ->
Astlib.Ast_502.Parsetree.constant ->
Astlib.Ast_502.Parsetree.patternppat_interval constructs an Ast.pattern_desc.Ppat_interval
Example OCaml
Patterns such as 'a'..'z'.
Other forms of interval are recognized by the parser but rejected by the type-checker.
val ppat_constant :
loc:Location.t ->
Astlib.Ast_502.Parsetree.constant ->
Astlib.Ast_502.Parsetree.patternppat_constant constructs an Ast.pattern_desc.Ppat_constant
Example OCaml
Patterns such as 1, 'a', "true", 1.0, 1l, 1L, 1n
val ppat_alias :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.patternval ppat_var :
loc:Location.t ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.patternval ppat_any : loc:Location.t -> Astlib.Ast_502.Parsetree.patternval oinherit :
loc:Location.t ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.object_fieldoinherit constructs an Ast.object_field_desc.Oinherit
val otag :
loc:Location.t ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.object_fieldotag constructs an Ast.object_field_desc.Otag
val module_type_declaration :
loc:Location.t ->
name:string Astlib.Location.loc ->
type_:Astlib.Ast_502.Parsetree.module_type option ->
Astlib.Ast_502.Parsetree.module_type_declarationmodule_type_declaration constructs an Ast.module_type_declaration
Example OCaml
Values of type module_type_declaration represents:
S = MT,S for abstract module type declaration, when pmtd_type is None.val pmty_alias :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.module_typeval pmty_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.module_typeval pmty_typeof :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_typeval pmty_with :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_type ->
Astlib.Ast_502.Parsetree.with_constraint list ->
Astlib.Ast_502.Parsetree.module_typeval pmty_functor :
loc:Location.t ->
Astlib.Ast_502.Parsetree.functor_parameter ->
Astlib.Ast_502.Parsetree.module_type ->
Astlib.Ast_502.Parsetree.module_typeval pmty_signature :
loc:Location.t ->
Astlib.Ast_502.Parsetree.signature_item list ->
Astlib.Ast_502.Parsetree.module_typeval pmty_ident :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.module_typeval module_substitution :
loc:Location.t ->
name:string Astlib.Location.loc ->
manifest:Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.module_substitutionmodule_substitution constructs an Ast.module_substitution
Example OCaml
Values of type module_substitution represents S := M
val pmod_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.module_exprval pmod_unpack :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.module_exprval pmod_constraint :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_type ->
Astlib.Ast_502.Parsetree.module_exprval pmod_apply_unit :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_exprval pmod_apply :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_exprval pmod_functor :
loc:Location.t ->
Astlib.Ast_502.Parsetree.functor_parameter ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_exprval pmod_structure :
loc:Location.t ->
Astlib.Ast_502.Parsetree.structure_item list ->
Astlib.Ast_502.Parsetree.module_exprval pmod_ident :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.module_exprval module_declaration :
loc:Location.t ->
name:string option Astlib.Location.loc ->
type_:Astlib.Ast_502.Parsetree.module_type ->
Astlib.Ast_502.Parsetree.module_declarationmodule_declaration constructs an Ast.module_declaration
Example OCaml
Values of type module_declaration represents S : MT
val module_binding :
loc:Location.t ->
name:string option Astlib.Location.loc ->
expr:Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.module_bindingmodule_binding constructs an Ast.module_binding
Example OCaml
Values of type module_binding represents module X = ME
val location :
start:Stdlib.Lexing.position ->
end_:Stdlib.Lexing.position ->
ghost:bool ->
Astlib.Location.tlocation constructs an Ast.location
val letop :
let_:Astlib.Ast_502.Parsetree.binding_op ->
ands:Astlib.Ast_502.Parsetree.binding_op list ->
body:Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.letopletop constructs an Ast.letop
val label_declaration :
loc:Location.t ->
name:string Astlib.Location.loc ->
mutable_:Astlib.Ast_502.Asttypes.mutable_flag ->
type_:Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.label_declarationlabel_declaration constructs an Ast.label_declaration
Example OCaml
{ ...; l: T; ... } when pld_mutable is Immutable,{ ...; mutable l: T; ... } when pld_mutable is Mutable.Note: T can be a Ptyp_poly.
val pparam_newtype :
loc:Location.t ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.function_parampparam_newtype constructs an Ast.function_param_desc.Pparam_newtype
Example OCaml
Pparam_newtype x represents the parameter (type x). x carries the location of the identifier, whereas the pparam_loc on the enclosing function_param node is the location of the (type x) as a whole.
Multiple parameters (type a b c) are represented as multiple Pparam_newtype nodes, let's say:
[
{ pparam_kind = Pparam_newtype a; pparam_loc = loc1 };
{ pparam_kind = Pparam_newtype b; pparam_loc = loc2 };
{ pparam_kind = Pparam_newtype c; pparam_loc = loc3 };
]Here, the first loc loc1 is the location of (type a b c), and the subsequent locs loc2 and loc3 are the same as loc1, except marked as ghost locations. The locations on a, b, c, correspond to the variables a, b, and c in the source code.
val pparam_val :
loc:Location.t ->
Astlib.Ast_502.Asttypes.arg_label ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.function_parampparam_val constructs an Ast.function_param_desc.Pparam_val
Example OCaml
Pparam_val (lbl, exp0, P) represents the parameter:
P when lbl is Nolabel and exp0 is None~l:P when lbl is Labelled l and exp0 is None?l:P when lbl is Optional l and exp0 is None?l:(P = E0) when lbl is Optional l and exp0 is Some E0Note: If E0 is provided, only Optional is allowed.
val extension_constructor :
loc:Location.t ->
name:string Astlib.Location.loc ->
kind:Astlib.Ast_502.Parsetree.extension_constructor_kind ->
Astlib.Ast_502.Parsetree.extension_constructorextension_constructor constructs an Ast.extension_constructor
val pexp_unreachable : loc:Location.t -> Astlib.Ast_502.Parsetree.expressionval pexp_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.expressionval pexp_letop :
loc:Location.t ->
Astlib.Ast_502.Parsetree.letop ->
Astlib.Ast_502.Parsetree.expressionpexp_letop constructs an Ast.expression_desc.Pexp_letop
Example OCaml
let* P = E0 in E1let* P0 = E00 and* P1 = E01 in E1val pexp_open :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr Astlib.Ast_502.Parsetree.open_infos ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_open constructs an Ast.expression_desc.Pexp_open
Example OCaml
M.(E)let open M in Elet open! M in Eval pexp_pack :
loc:Location.t ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.expressionpexp_pack constructs an Ast.expression_desc.Pexp_pack
Example OCaml
(module ME).
(module ME : S) is represented as Pexp_constraint(Pexp_pack ME, Ptyp_package S)
val pexp_newtype :
loc:Location.t ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_object :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_structure ->
Astlib.Ast_502.Parsetree.expressionval pexp_poly :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.core_type option ->
Astlib.Ast_502.Parsetree.expressionpexp_poly constructs an Ast.expression_desc.Pexp_poly
Example OCaml
Used for method bodies.
Can only be used as the expression under Cfk_concrete for methods (not values).
val pexp_lazy :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_assert :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_assert constructs an Ast.expression_desc.Pexp_assert
Example OCaml
assert E.
Note: assert false is treated in a special way by the type-checker.
val pexp_letexception :
loc:Location.t ->
Astlib.Ast_502.Parsetree.extension_constructor ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_letexception constructs an Ast.expression_desc.Pexp_letexception
Example OCaml
let exception C in E
val pexp_letmodule :
loc:Location.t ->
string option Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.module_expr ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_override :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.expression) list ->
Astlib.Ast_502.Parsetree.expressionpexp_override constructs an Ast.expression_desc.Pexp_override
Example OCaml
{< x1 = E1; ...; xn = En >}
val pexp_setinstvar :
loc:Location.t ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_new :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expressionval pexp_send :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expressionval pexp_coerce :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.core_type option ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.expressionpexp_coerce constructs an Ast.expression_desc.Pexp_coerce
Example OCaml
Pexp_coerce(E, from, T) represents
(E :> T) when from is None,(E : T0 :> T) when from is Some T0.val pexp_constraint :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.expressionval pexp_for :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Asttypes.direction_flag ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_for constructs an Ast.expression_desc.Pexp_for
Example OCaml
Pexp_for(i, E1, E2, direction, E3) represents:
val pexp_while :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_sequence :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_ifthenelse :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.expressionval pexp_array :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionval pexp_setfield :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval pexp_field :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expressionval pexp_record :
loc:Location.t ->
(Astlib.Longident.t Astlib.Location.loc * Astlib.Ast_502.Parsetree.expression)
list ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.expressionpexp_record constructs an Ast.expression_desc.Pexp_record
Example OCaml
Pexp_record([(l1,P1) ; ... ; (ln,Pn)], exp0) represents
{ l1=P1; ...; ln=Pn } when exp0 is None{ E0 with l1=P1; ...; ln=Pn } when exp0 is Some E0Invariant: n > 0
val pexp_variant :
loc:Location.t ->
string ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.expressionpexp_variant constructs an Ast.expression_desc.Pexp_variant
Example OCaml
Pexp_variant(`A, exp) represents
`A when exp is None`A E when exp is Some Eval pexp_construct :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.expressionpexp_construct constructs an Ast.expression_desc.Pexp_construct
Example OCaml
Pexp_construct(C, exp) represents:
C when exp is None,C E when exp is Some E,C (E1, ..., En) when exp is Some (Pexp_tuple[E1;...;En])val pexp_tuple :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionpexp_tuple constructs an Ast.expression_desc.Pexp_tuple
Example OCaml
Expressions (E1, ..., En)
Invariant: n >= 2
val pexp_try :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.case list ->
Astlib.Ast_502.Parsetree.expressionpexp_try constructs an Ast.expression_desc.Pexp_try
Example OCaml
try E0 with P1 -> E1 | ... | Pn -> En
val pexp_match :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.case list ->
Astlib.Ast_502.Parsetree.expressionpexp_match constructs an Ast.expression_desc.Pexp_match
Example OCaml
match E0 with P1 -> E1 | ... | Pn -> En
val pexp_apply :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
(Astlib.Ast_502.Asttypes.arg_label * Astlib.Ast_502.Parsetree.expression)
list ->
Astlib.Ast_502.Parsetree.expressionpexp_apply constructs an Ast.expression_desc.Pexp_apply
Example OCaml
Pexp_apply(E0, [(l1, E1) ; ... ; (ln, En)]) represents E0 ~l1:E1 ... ~ln:En
li can be Nolabel (non labeled argument), Labelled (labelled arguments) or Optional (optional argument).
Invariant: n > 0
val pexp_let :
loc:Location.t ->
Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.value_binding list ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_let constructs an Ast.expression_desc.Pexp_let
Example OCaml
Pexp_let(flag, [(P1,E1) ; ... ; (Pn,En)], E) represents:
let P1 = E1 and ... and Pn = EN in E when flag is Nonrecursive,let rec P1 = E1 and ... and Pn = EN in E when flag is Recursive.val pexp_constant :
loc:Location.t ->
Astlib.Ast_502.Parsetree.constant ->
Astlib.Ast_502.Parsetree.expressionpexp_constant constructs an Ast.expression_desc.Pexp_constant
Example OCaml
Expressions constant such as 1, 'a', "true", 1.0, 1l, 1L, 1n
val pexp_ident :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.expressionval pdir_bool :
loc:Location.t ->
bool ->
Astlib.Ast_502.Parsetree.directive_argumentpdir_bool constructs an Ast.directive_argument_desc.Pdir_bool
val pdir_ident :
loc:Location.t ->
Astlib.Longident.t ->
Astlib.Ast_502.Parsetree.directive_argumentpdir_ident constructs an Ast.directive_argument_desc.Pdir_ident
val pdir_int :
loc:Location.t ->
string ->
char option ->
Astlib.Ast_502.Parsetree.directive_argumentpdir_int constructs an Ast.directive_argument_desc.Pdir_int
val pdir_string :
loc:Location.t ->
string ->
Astlib.Ast_502.Parsetree.directive_argumentpdir_string constructs an Ast.directive_argument_desc.Pdir_string
val ptyp_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.core_typeval ptyp_open :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.core_typeval ptyp_package :
loc:Location.t ->
(Astlib.Longident.t Astlib.Location.loc
* (Astlib.Longident.t Astlib.Location.loc
* Astlib.Ast_502.Parsetree.core_type)
list) ->
Astlib.Ast_502.Parsetree.core_typeval ptyp_poly :
loc:Location.t ->
string Astlib.Location.loc list ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.core_typeptyp_poly constructs an Ast.core_type_desc.Ptyp_poly
Example OCaml
'a1 ... 'an. T
Can only appear in the following context:
core_type of a Ppat_constraint node corresponding to a constraint on a let-binding: let x : 'a1 ... 'an. T = e ...Cfk_virtual for methods (not values).core_type of a Pctf_method node.pld_type field of a label_declaration.core_type of a Ptyp_object node.pval_type field of a value_description.val ptyp_variant :
loc:Location.t ->
Astlib.Ast_502.Parsetree.row_field list ->
Astlib.Ast_502.Asttypes.closed_flag ->
string list option ->
Astlib.Ast_502.Parsetree.core_typeptyp_variant constructs an Ast.core_type_desc.Ptyp_variant
Example OCaml
Ptyp_variant([`A;`B], flag, labels) represents:
val ptyp_alias :
loc:Location.t ->
Astlib.Ast_502.Parsetree.core_type ->
string Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_typeval ptyp_class :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.core_typeptyp_class constructs an Ast.core_type_desc.Ptyp_class
Example OCaml
Ptyp_class(tconstr, l) represents:
#tconstr when l=[],T #tconstr when l=[T],(T1, ..., Tn) #tconstr when l=[T1 ; ... ; Tn].val ptyp_object :
loc:Location.t ->
Astlib.Ast_502.Parsetree.object_field list ->
Astlib.Ast_502.Asttypes.closed_flag ->
Astlib.Ast_502.Parsetree.core_typeptyp_object constructs an Ast.core_type_desc.Ptyp_object
Example OCaml
Ptyp_object([ l1:T1; ...; ln:Tn ], flag) represents:
val ptyp_constr :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.core_typeptyp_constr constructs an Ast.core_type_desc.Ptyp_constr
Example OCaml
Ptyp_constr(lident, l) represents:
tconstr when l=[],T tconstr when l=[T],(T1, ..., Tn) tconstr when l=[T1 ; ... ; Tn].val ptyp_tuple :
loc:Location.t ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.core_typeptyp_tuple constructs an Ast.core_type_desc.Ptyp_tuple
Example OCaml
Ptyp_tuple([T1 ; ... ; Tn]) represents a product type T1 * ... * Tn.
Invariant: n >= 2.
val ptyp_arrow :
loc:Location.t ->
Astlib.Ast_502.Asttypes.arg_label ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.core_typeptyp_arrow constructs an Ast.core_type_desc.Ptyp_arrow
Example OCaml
Ptyp_arrow(lbl, T1, T2) represents:
val ptyp_var : loc:Location.t -> string -> Astlib.Ast_502.Parsetree.core_typeval ptyp_any : loc:Location.t -> Astlib.Ast_502.Parsetree.core_typeval pctf_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.class_type_fieldval pctf_attribute :
loc:Location.t ->
Astlib.Ast_502.Parsetree.attribute ->
Astlib.Ast_502.Parsetree.class_type_fieldval pctf_constraint :
loc:Location.t ->
(Astlib.Ast_502.Parsetree.core_type * Astlib.Ast_502.Parsetree.core_type) ->
Astlib.Ast_502.Parsetree.class_type_fieldpctf_constraint constructs an Ast.class_type_field_desc.Pctf_constraint
Example OCaml
constraint T1 = T2
val pctf_method :
loc:Location.t ->
(string Astlib.Location.loc
* Astlib.Ast_502.Asttypes.private_flag
* Astlib.Ast_502.Asttypes.virtual_flag
* Astlib.Ast_502.Parsetree.core_type) ->
Astlib.Ast_502.Parsetree.class_type_fieldpctf_method constructs an Ast.class_type_field_desc.Pctf_method
Example OCaml
method x: T
Note: T can be a Ptyp_poly.
val pctf_val :
loc:Location.t ->
(string Astlib.Location.loc
* Astlib.Ast_502.Asttypes.mutable_flag
* Astlib.Ast_502.Asttypes.virtual_flag
* Astlib.Ast_502.Parsetree.core_type) ->
Astlib.Ast_502.Parsetree.class_type_fieldval pctf_inherit :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_type ->
Astlib.Ast_502.Parsetree.class_type_fieldval pcty_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.class_typeval pcty_arrow :
loc:Location.t ->
Astlib.Ast_502.Asttypes.arg_label ->
Astlib.Ast_502.Parsetree.core_type ->
Astlib.Ast_502.Parsetree.class_type ->
Astlib.Ast_502.Parsetree.class_typepcty_arrow constructs an Ast.class_type_desc.Pcty_arrow
Example OCaml
Pcty_arrow(lbl, T, CT) represents:
T -> CT when lbl is Nolabel,~l:T -> CT when lbl is Labelled l,?l:T -> CT when lbl is Optional l.val pcty_signature :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_signature ->
Astlib.Ast_502.Parsetree.class_typeval pcty_constr :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.class_typeval class_structure :
self:Astlib.Ast_502.Parsetree.pattern ->
fields:Astlib.Ast_502.Parsetree.class_field list ->
Astlib.Ast_502.Parsetree.class_structureclass_structure constructs an Ast.class_structure
Example OCaml
Values of type class_structure represents:
object(selfpat) ... endobject ... end when pcstr_self is Ppat_anyval class_signature :
self:Astlib.Ast_502.Parsetree.core_type ->
fields:Astlib.Ast_502.Parsetree.class_type_field list ->
Astlib.Ast_502.Parsetree.class_signatureclass_signature constructs an Ast.class_signature
Example OCaml
Values of type class_signature represents:
object('selfpat) ... endobject ... end when pcsig_self is Ptyp_anyval pcf_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.class_fieldval pcf_attribute :
loc:Location.t ->
Astlib.Ast_502.Parsetree.attribute ->
Astlib.Ast_502.Parsetree.class_fieldval pcf_initializer :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.class_fieldval pcf_constraint :
loc:Location.t ->
(Astlib.Ast_502.Parsetree.core_type * Astlib.Ast_502.Parsetree.core_type) ->
Astlib.Ast_502.Parsetree.class_fieldval pcf_method :
loc:Location.t ->
(string Astlib.Location.loc
* Astlib.Ast_502.Asttypes.private_flag
* Astlib.Ast_502.Parsetree.class_field_kind) ->
Astlib.Ast_502.Parsetree.class_fieldpcf_method constructs an Ast.class_field_desc.Pcf_method
Example OCaml
val pcf_val :
loc:Location.t ->
(string Astlib.Location.loc
* Astlib.Ast_502.Asttypes.mutable_flag
* Astlib.Ast_502.Parsetree.class_field_kind) ->
Astlib.Ast_502.Parsetree.class_fieldpcf_val constructs an Ast.class_field_desc.Pcf_val
Example OCaml
Pcf_val(x,flag, kind) represents:
val x = E when flag is Immutable and kind is Cfk_concrete(Fresh, E)val virtual x: T when flag is Immutable and kind is Cfk_virtual(T)val mutable x = E when flag is Mutable and kind is Cfk_concrete(Fresh, E)val mutable virtual x: T when flag is Mutable and kind is Cfk_virtual(T)val pcf_inherit :
loc:Location.t ->
Astlib.Ast_502.Asttypes.override_flag ->
Astlib.Ast_502.Parsetree.class_expr ->
string Astlib.Location.loc option ->
Astlib.Ast_502.Parsetree.class_fieldpcf_inherit constructs an Ast.class_field_desc.Pcf_inherit
Example OCaml
Pcf_inherit(flag, CE, s) represents:
val pcl_extension :
loc:Location.t ->
(string Astlib.Location.loc * Astlib.Ast_502.Parsetree.payload) ->
Astlib.Ast_502.Parsetree.class_exprval pcl_constraint :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_expr ->
Astlib.Ast_502.Parsetree.class_type ->
Astlib.Ast_502.Parsetree.class_exprval pcl_let :
loc:Location.t ->
Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.value_binding list ->
Astlib.Ast_502.Parsetree.class_expr ->
Astlib.Ast_502.Parsetree.class_exprpcl_let constructs an Ast.class_expr_desc.Pcl_let
Example OCaml
Pcl_let(rec, [(P1, E1); ... ; (Pn, En)], CE) represents:
let P1 = E1 and ... and Pn = EN in CE when rec is Nonrecursive,let rec P1 = E1 and ... and Pn = EN in CE when rec is Recursive.val pcl_apply :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_expr ->
(Astlib.Ast_502.Asttypes.arg_label * Astlib.Ast_502.Parsetree.expression)
list ->
Astlib.Ast_502.Parsetree.class_exprpcl_apply constructs an Ast.class_expr_desc.Pcl_apply
Example OCaml
Pcl_apply(CE, [(l1,E1) ; ... ; (ln,En)]) represents CE ~l1:E1 ... ~ln:En. li can be empty (non labeled argument) or start with ? (optional argument).
Invariant: n > 0
val pcl_fun :
loc:Location.t ->
Astlib.Ast_502.Asttypes.arg_label ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.class_expr ->
Astlib.Ast_502.Parsetree.class_exprpcl_fun constructs an Ast.class_expr_desc.Pcl_fun
Example OCaml
Pcl_fun(lbl, exp0, P, CE) represents:
fun P -> CE when lbl is Nolabel and exp0 is None,fun ~l:P -> CE when lbl is Labelled l and exp0 is None,fun ?l:P -> CE when lbl is Optional l and exp0 is None,fun ?l:(P = E0) -> CE when lbl is Optional l and exp0 is Some E0.val pcl_structure :
loc:Location.t ->
Astlib.Ast_502.Parsetree.class_structure ->
Astlib.Ast_502.Parsetree.class_exprval pcl_constr :
loc:Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.core_type list ->
Astlib.Ast_502.Parsetree.class_exprval case :
lhs:Astlib.Ast_502.Parsetree.pattern ->
guard:Astlib.Ast_502.Parsetree.expression option ->
rhs:Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.caseval binding_op :
loc:Location.t ->
op:string Astlib.Location.loc ->
pat:Astlib.Ast_502.Parsetree.pattern ->
exp:Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.binding_opbinding_op constructs an Ast.binding_op
val attribute :
loc:Location.t ->
name:string Astlib.Location.loc ->
payload:Astlib.Ast_502.Parsetree.payload ->
Astlib.Ast_502.Parsetree.attributeattribute constructs an Ast.attribute
Example OCaml
Attributes such as [\@id ARG] and [\@\@id ARG].
Metadata containers passed around within the AST. The compiler ignores unknown attributes.
val open_infos :
loc:Location.t ->
expr:'a ->
override:Astlib.Ast_502.Asttypes.override_flag ->
'a Astlib.Ast_502.Parsetree.open_infosopen_infos constructs an Ast.'aopen_infos
Example OCaml
Values of type 'a open_infos represents:
open! X when popen_override is Override (silences the "used identifier shadowing" warning)open X when popen_override is Freshval include_infos :
loc:Location.t ->
'a ->
'a Astlib.Ast_502.Parsetree.include_infosinclude_infos constructs an Ast.'ainclude_infos
val class_infos :
loc:Location.t ->
virt:Astlib.Ast_502.Asttypes.virtual_flag ->
params:
(Astlib.Ast_502.Parsetree.core_type
* (Astlib.Ast_502.Asttypes.variance * Astlib.Ast_502.Asttypes.injectivity))
list ->
name:string Astlib.Location.loc ->
expr:'a ->
'a Astlib.Ast_502.Parsetree.class_infosclass_infos constructs an Ast.'aclass_infos
Example OCaml
Values of type class_expr class_infos represents:
class c = ...class ['a1,...,'an] c = ...class virtual c = ...They are also used for "class type" declaration.
module Latest : sig ... endThis module contains updated versions of node constructors that were kept stable when the node changed. For every function in this module, there's an equally-named function outside this module. The function outside this module will stay stable, whereas the function inside this module will adapt potential upcoming new compiler features. Only use a function in this module, if the equally-named one outside this module is missing a feature you need.
val ppat_construct :
loc:Astlib.Location.t ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_502.Parsetree.pattern option ->
Astlib.Ast_502.Parsetree.patternval coalesce_arity :
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionIf an expression e is a function of arity n with a body that is another function with arity m, then coalesce_arity e will produce a function of arity n + m. This will not run recursively, so an expression fun x -> fun y -> fun z -> x + y + z will become fun x y -> fun z -> x + y + z.
val constructor_declaration :
loc:Astlib.Location.t ->
name:string Astlib.Location.loc ->
args:Astlib.Ast_502.Parsetree.constructor_arguments ->
res:Astlib.Ast_502.Parsetree.core_type option ->
Astlib.Ast_502.Parsetree.constructor_declarationval eint : loc:Location.t -> int -> Astlib.Ast_502.Parsetree.expressionval echar : loc:Location.t -> char -> Astlib.Ast_502.Parsetree.expressionval estring : loc:Location.t -> string -> Astlib.Ast_502.Parsetree.expressionval efloat : loc:Location.t -> string -> Astlib.Ast_502.Parsetree.expressionval eint32 : loc:Location.t -> int32 -> Astlib.Ast_502.Parsetree.expressionval eint64 : loc:Location.t -> int64 -> Astlib.Ast_502.Parsetree.expressionval enativeint :
loc:Location.t ->
nativeint ->
Astlib.Ast_502.Parsetree.expressionval ebool : loc:Location.t -> bool -> Astlib.Ast_502.Parsetree.expressionval pint : loc:Location.t -> int -> Astlib.Ast_502.Parsetree.patternval pchar : loc:Location.t -> char -> Astlib.Ast_502.Parsetree.patternval pstring : loc:Location.t -> string -> Astlib.Ast_502.Parsetree.patternval pfloat : loc:Location.t -> string -> Astlib.Ast_502.Parsetree.patternval pint32 : loc:Location.t -> int32 -> Astlib.Ast_502.Parsetree.patternval pint64 : loc:Location.t -> int64 -> Astlib.Ast_502.Parsetree.patternval pnativeint :
loc:Location.t ->
nativeint ->
Astlib.Ast_502.Parsetree.patternval pbool : loc:Location.t -> bool -> Astlib.Ast_502.Parsetree.patternval eunit : loc:Location.t -> Astlib.Ast_502.Parsetree.expressionval punit : loc:Location.t -> Astlib.Ast_502.Parsetree.patternval evar : loc:Location.t -> string -> Astlib.Ast_502.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 -> Astlib.Ast_502.Parsetree.patternval eapply :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionSame as pexp_apply but without labels
val eabstract :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval esequence :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionval ppat_tuple_opt :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.pattern optionval pexp_tuple_opt :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expression optionval pexp_fun :
loc:Location.t ->
Astlib.Ast_502.Asttypes.arg_label ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionpexp_fun can be used to create function expressions. It will check if the function's body is itself a function expression and if so it will coalesce the arguments.
For example, if we have pexp_fun Nolabel None (var "x") f and f is fun y -> x + y then the function expression returned will be fun x y -> x + y and not fun x -> y -> x + y. However, it will be more efficient to create maximum arity functions directly with pexp_function.
val pexp_function :
loc:Location.t ->
Astlib.Ast_502.Parsetree.function_param list ->
Astlib.Ast_502.Parsetree.type_constraint option ->
Astlib.Ast_502.Parsetree.function_body ->
Astlib.Ast_502.Parsetree.expressionval pexp_function_cases :
loc:Location.t ->
Astlib.Ast_502.Parsetree.case list ->
Astlib.Ast_502.Parsetree.expressionpexp_function_cases builds an expression in the shape function C1 -> E1 | ....
val pconstruct :
Astlib.Ast_502.Parsetree.constructor_declaration ->
Astlib.Ast_502.Parsetree.pattern option ->
Astlib.Ast_502.Parsetree.patternval econstruct :
Astlib.Ast_502.Parsetree.constructor_declaration ->
Astlib.Ast_502.Parsetree.expression option ->
Astlib.Ast_502.Parsetree.expressionval elist_tail :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionelist_tail ~loc [expr1; expr2; expr3] expr_tail produces the expression expr1::expr2::expr3::expr_tail.
val elist :
loc:Location.t ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionelist ~loc [expr1; expr2; expr3] produces the list litteral expression [expr1; expr2; expr3].
val plist_tail :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.pattern ->
Astlib.Ast_502.Parsetree.patternplist_tail ~loc [pat1; pat2; pat3] pat_tail produces the pattern pat1::pat2::pat3::pat_tail.
val plist :
loc:Location.t ->
Astlib.Ast_502.Parsetree.pattern list ->
Astlib.Ast_502.Parsetree.patternplist ~loc [pat1; pat2; pat3] produces the list pattern [pat1; pat2; pat3].
val value_binding :
loc:Location.t ->
pat:Astlib.Ast_502.Parsetree.pattern ->
expr:Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.value_bindingval pstr_value_list :
loc:Location.t ->
Ppxlib_ast.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.value_binding list ->
Astlib.Ast_502.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:
(Astlib.Ast_502.Parsetree.core_type * Ppxlib_ast.Asttypes.variance) list ->
cstrs:
(Astlib.Ast_502.Parsetree.core_type
* Astlib.Ast_502.Parsetree.core_type
* Location.t)
list ->
kind:Astlib.Ast_502.Parsetree.type_kind ->
private_:Ppxlib_ast.Asttypes.private_flag ->
manifest:Astlib.Ast_502.Parsetree.core_type option ->
Astlib.Ast_502.Parsetree.type_declarationval unapplied_type_constr_conv :
loc:Location.t ->
Longident.t Loc.t ->
f:(string -> string) ->
Astlib.Ast_502.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) ->
Astlib.Ast_502.Parsetree.expression list ->
Astlib.Ast_502.Parsetree.expressionval eta_reduce :
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.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 :
Astlib.Ast_502.Parsetree.expression ->
Astlib.Ast_502.Parsetree.expressionval eta_reduce_if_possible_and_nonrec :
Astlib.Ast_502.Parsetree.expression ->
rec_flag:Astlib.Ast_502.Asttypes.rec_flag ->
Astlib.Ast_502.Parsetree.expression