package ppx_repr
- Value description
- Value binding
- Type extension
- Type exception
- Type declaration
- Toplevel directive
- Structure item
- Signature item
- Row field
- Position
- Pattern
- Object field
- Module type declaration
- Module type
- Module substitution
- Module expr
- Module declaration
- Module binding
- Location
- Letop
- Label declaration
- Extension constructor
- Expression
- Directive argument
- Core type
- Constructor declaration
- Class type field
- Class type
- Class structure
- Class signature
- Class field
- Class expr
- Case
- Binding op
- Attribute
- 'a open infos
- 'a include infos
- 'a class infos
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=bb8a0f94df002fc19dcb598834271eaddeffa1d57041491ff3d2b9e3e80d075e
sha512=2218845ba1b42e3983bc9727879c704433571655c85251c43edb9bf85ceec35c3b662091e32a744a5340a9c641b1cb5fa591389a68832faf0bb71981d6d91e1d
doc/ppx_repr.lib/Ppx_repr_lib/Engine/Located/argument-2-_/index.html
Parameter Located._
module Located : sig ... endval loc : Ppxlib.Location.tValue description
val value_description :
name:string Astlib.Location.loc ->
type_:Astlib.Ast_500.Parsetree.core_type ->
prim:string list ->
Astlib.Ast_500.Parsetree.value_descriptionvalue_description constructs an Ast.value_description
Example OCaml
Values of type value_description represents:
val x: T, whenpval_primis[]external x: T = "s1" ... "sn"whenpval_primis["s1";..."sn"]
Value binding
val value_binding :
pat:Astlib.Ast_500.Parsetree.pattern ->
expr:Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.value_bindingvalue_binding constructs an Ast.value_binding
Type extension
val type_extension :
path:Astlib.Longident.t Astlib.Location.loc ->
params:
(Astlib.Ast_500.Parsetree.core_type
* (Astlib.Ast_500.Asttypes.variance * Astlib.Ast_500.Asttypes.injectivity))
list ->
constructors:Astlib.Ast_500.Parsetree.extension_constructor list ->
private_:Astlib.Ast_500.Asttypes.private_flag ->
Astlib.Ast_500.Parsetree.type_extensiontype_extension constructs an Ast.type_extension
Example OCaml
Definition of new extensions constructors for the extensive sum type t (type t += ...).
Type exception
val type_exception :
Astlib.Ast_500.Parsetree.extension_constructor ->
Astlib.Ast_500.Parsetree.type_exceptiontype_exception constructs an Ast.type_exception
Example OCaml
Definition of a new exception (exception E).
Type declaration
val type_declaration :
name:string Astlib.Location.loc ->
params:
(Astlib.Ast_500.Parsetree.core_type
* (Astlib.Ast_500.Asttypes.variance * Astlib.Ast_500.Asttypes.injectivity))
list ->
cstrs:
(Astlib.Ast_500.Parsetree.core_type
* Astlib.Ast_500.Parsetree.core_type
* Astlib.Location.t)
list ->
kind:Astlib.Ast_500.Parsetree.type_kind ->
private_:Astlib.Ast_500.Asttypes.private_flag ->
manifest:Astlib.Ast_500.Parsetree.core_type option ->
Astlib.Ast_500.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 twhentype_kindisPtype_abstract, andmanifestisNone,type t = T0whentype_kindisPtype_abstract, andmanifestisSome T0,type t = C of T | ...whentype_kindisPtype_variant, andmanifestisNone,type t = T0 = C of T | ...whentype_kindisPtype_variant, andmanifestisSome T0,type t = {l: T; ...}whentype_kindisPtype_record, andmanifestisNone,type t = T0 = {l : T; ...}whentype_kindisPtype_record, andmanifestisSome T0,type t = ..whentype_kindisPtype_open, andmanifestisNone.
Toplevel directive
val toplevel_directive :
name:string Astlib.Location.loc ->
arg:Astlib.Ast_500.Parsetree.directive_argument option ->
Astlib.Ast_500.Parsetree.toplevel_directivetoplevel_directive constructs an Ast.toplevel_directive
Structure item
val pstr_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.attribute list ->
Astlib.Ast_500.Parsetree.structure_itempstr_extension constructs an Ast.Pstr_extension
Example OCaml
[%%id]
pstr_attribute constructs an Ast.Pstr_attribute
Example OCaml
[@@@id]
val pstr_include :
Astlib.Ast_500.Parsetree.module_expr Astlib.Ast_500.Parsetree.include_infos ->
Astlib.Ast_500.Parsetree.structure_itempstr_include constructs an Ast.Pstr_include
Example OCaml
include ME
val pstr_class_type :
Astlib.Ast_500.Parsetree.class_type Astlib.Ast_500.Parsetree.class_infos list ->
Astlib.Ast_500.Parsetree.structure_itempstr_class_type constructs an Ast.Pstr_class_type
Example OCaml
class type ct1 = ... and ... and ctn = ...
val pstr_class :
Astlib.Ast_500.Parsetree.class_expr Astlib.Ast_500.Parsetree.class_infos list ->
Astlib.Ast_500.Parsetree.structure_itempstr_class constructs an Ast.Pstr_class
Example OCaml
class c1 = ... and ... and cn = ...
val pstr_open :
Astlib.Ast_500.Parsetree.module_expr Astlib.Ast_500.Parsetree.open_infos ->
Astlib.Ast_500.Parsetree.structure_itempstr_open constructs an Ast.Pstr_open
Example OCaml
open X
val pstr_modtype :
Astlib.Ast_500.Parsetree.module_type_declaration ->
Astlib.Ast_500.Parsetree.structure_itempstr_modtype constructs an Ast.Pstr_modtype
Example OCaml
module type S = MT
val pstr_recmodule :
Astlib.Ast_500.Parsetree.module_binding list ->
Astlib.Ast_500.Parsetree.structure_itempstr_recmodule constructs an Ast.Pstr_recmodule
Example OCaml
module rec X1 = ME1 and ... and Xn = MEn
val pstr_module :
Astlib.Ast_500.Parsetree.module_binding ->
Astlib.Ast_500.Parsetree.structure_itempstr_module constructs an Ast.Pstr_module
Example OCaml
module X = ME
val pstr_exception :
Astlib.Ast_500.Parsetree.type_exception ->
Astlib.Ast_500.Parsetree.structure_itempstr_exception constructs an Ast.Pstr_exception
Example OCaml
exception C of Texception C = M.X
val pstr_typext :
Astlib.Ast_500.Parsetree.type_extension ->
Astlib.Ast_500.Parsetree.structure_itempstr_typext constructs an Ast.Pstr_typext
Example OCaml
type t1 += ...
val pstr_type :
Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.type_declaration list ->
Astlib.Ast_500.Parsetree.structure_itempstr_type constructs an Ast.Pstr_type
Example OCaml
type t1 = ... and ... and tn = ...
val pstr_primitive :
Astlib.Ast_500.Parsetree.value_description ->
Astlib.Ast_500.Parsetree.structure_itempstr_primitive constructs an Ast.Pstr_primitive
Example OCaml
val x: Texternal x: T = "s1" ... "sn"
val pstr_value :
Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.value_binding list ->
Astlib.Ast_500.Parsetree.structure_itempstr_value constructs an Ast.Pstr_value
Example OCaml
Pstr_value(rec, [(P1, E1 ; ... ; (Pn, En))]) represents:
let P1 = E1 and ... and Pn = ENwhenrecisNonrecursive,let rec P1 = E1 and ... and Pn = ENwhenrecisRecursive.
val pstr_eval :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.attribute list ->
Astlib.Ast_500.Parsetree.structure_itempstr_eval constructs an Ast.Pstr_eval
Example OCaml
E
Signature item
val psig_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.attribute list ->
Astlib.Ast_500.Parsetree.signature_itempsig_extension constructs an Ast.Psig_extension
Example OCaml
[%%id]
psig_attribute constructs an Ast.Psig_attribute
Example OCaml
[@@@id]
val psig_class_type :
Astlib.Ast_500.Parsetree.class_type Astlib.Ast_500.Parsetree.class_infos list ->
Astlib.Ast_500.Parsetree.signature_itempsig_class_type constructs an Ast.Psig_class_type
Example OCaml
class type ct1 = ... and ... and ctn = ...
val psig_class :
Astlib.Ast_500.Parsetree.class_type Astlib.Ast_500.Parsetree.class_infos list ->
Astlib.Ast_500.Parsetree.signature_itempsig_class constructs an Ast.Psig_class
Example OCaml
class c1 : ... and ... and cn : ...
val psig_include :
Astlib.Ast_500.Parsetree.module_type Astlib.Ast_500.Parsetree.include_infos ->
Astlib.Ast_500.Parsetree.signature_itempsig_include constructs an Ast.Psig_include
Example OCaml
include MT
val psig_open :
Astlib.Longident.t Astlib.Location.loc Astlib.Ast_500.Parsetree.open_infos ->
Astlib.Ast_500.Parsetree.signature_itempsig_open constructs an Ast.Psig_open
Example OCaml
open X
val psig_modtypesubst :
Astlib.Ast_500.Parsetree.module_type_declaration ->
Astlib.Ast_500.Parsetree.signature_itempsig_modtypesubst constructs an Ast.Psig_modtypesubst
Example OCaml
module type S := ...
val psig_modtype :
Astlib.Ast_500.Parsetree.module_type_declaration ->
Astlib.Ast_500.Parsetree.signature_itempsig_modtype constructs an Ast.Psig_modtype
Example OCaml
module type S = MT and module type S
val psig_recmodule :
Astlib.Ast_500.Parsetree.module_declaration list ->
Astlib.Ast_500.Parsetree.signature_itempsig_recmodule constructs an Ast.Psig_recmodule
Example OCaml
module rec X1 : MT1 and ... and Xn : MTn
val psig_modsubst :
Astlib.Ast_500.Parsetree.module_substitution ->
Astlib.Ast_500.Parsetree.signature_itempsig_modsubst constructs an Ast.Psig_modsubst
Example OCaml
module X := M
val psig_module :
Astlib.Ast_500.Parsetree.module_declaration ->
Astlib.Ast_500.Parsetree.signature_itempsig_module constructs an Ast.Psig_module
Example OCaml
module X = M and module X : MT
val psig_exception :
Astlib.Ast_500.Parsetree.type_exception ->
Astlib.Ast_500.Parsetree.signature_itempsig_exception constructs an Ast.Psig_exception
Example OCaml
exception C of T
val psig_typext :
Astlib.Ast_500.Parsetree.type_extension ->
Astlib.Ast_500.Parsetree.signature_itempsig_typext constructs an Ast.Psig_typext
Example OCaml
type t1 += ...
val psig_typesubst :
Astlib.Ast_500.Parsetree.type_declaration list ->
Astlib.Ast_500.Parsetree.signature_itempsig_typesubst constructs an Ast.Psig_typesubst
Example OCaml
type t1 := ... and ... and tn := ...
val psig_type :
Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.type_declaration list ->
Astlib.Ast_500.Parsetree.signature_itempsig_type constructs an Ast.Psig_type
Example OCaml
type t1 = ... and ... and tn = ...
val psig_value :
Astlib.Ast_500.Parsetree.value_description ->
Astlib.Ast_500.Parsetree.signature_itempsig_value constructs an Ast.Psig_value
Example OCaml
val x: Texternal x: T = "s1" ... "sn"
Row field
rinherit constructs an Ast.Rinherit
Example OCaml
[ | t ]
val rtag :
string Astlib.Location.loc ->
bool ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.row_fieldrtag constructs an Ast.Rtag
Example OCaml
Rtag(`A, b, l) represents:
`Awhenbistrueandlis[],`A of Twhenbisfalseandlis[T],`A of T1 & .. & Tnwhenbisfalseandlis[T1;...Tn],`A of & T1 & .. & Tnwhenbistrueandlis[T1;...Tn].
- The
boolfield 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
val position :
fname:string ->
lnum:int ->
bol:int ->
cnum:int ->
Lexing.positionposition constructs an Ast.position
Pattern
val ppat_open :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.patternppat_open constructs an Ast.Ppat_open
Example OCaml
Pattern M.(P)
val ppat_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.patternppat_extension constructs an Ast.Ppat_extension
Example OCaml
Pattern [%id]
ppat_exception constructs an Ast.Ppat_exception
Example OCaml
Pattern exception P
ppat_unpack constructs an Ast.Ppat_unpack
Example OCaml
Ppat_unpack(s) represents:
(module P)whensisSome "P"(module _)whensisNone
Note: (module P : S) is represented as Ppat_constraint(Ppat_unpack(Some "P"), Ptyp_package S)
ppat_lazy constructs an Ast.Ppat_lazy
Example OCaml
Pattern lazy P
ppat_type constructs an Ast.Ppat_type
Example OCaml
Pattern #tconst
val ppat_constraint :
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.patternppat_constraint constructs an Ast.Ppat_constraint
Example OCaml
Pattern (P : T)
val ppat_or :
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.patternppat_or constructs an Ast.Ppat_or
Example OCaml
Pattern P1 | P2
ppat_array constructs an Ast.Ppat_array
Example OCaml
Pattern [| P1; ...; Pn |]
val ppat_record :
(Astlib.Longident.t Astlib.Location.loc * Astlib.Ast_500.Parsetree.pattern)
list ->
Astlib.Ast_500.Asttypes.closed_flag ->
Astlib.Ast_500.Parsetree.patternppat_record constructs an Ast.Ppat_record
Example OCaml
Ppat_record([(l1, P1) ; ... ; (ln, Pn)], flag) represents:
{ l1=P1; ...; ln=Pn }whenflagisClosed{ l1=P1; ...; ln=Pn; _}whenflagisOpen
Invariant: n > 0
val ppat_variant :
string ->
Astlib.Ast_500.Parsetree.pattern option ->
Astlib.Ast_500.Parsetree.patternppat_variant constructs an Ast.Ppat_variant
Example OCaml
Ppat_variant(`A, pat) represents:
`AwhenpatisNone,`A PwhenpatisSome P
ppat_tuple constructs an Ast.Ppat_tuple
Example OCaml
Patterns (P1, ..., Pn).
Invariant: n >= 2
val ppat_interval :
Astlib.Ast_500.Parsetree.constant ->
Astlib.Ast_500.Parsetree.constant ->
Astlib.Ast_500.Parsetree.patternppat_interval constructs an Ast.Ppat_interval
Example OCaml
Patterns such as 'a'..'z'.
Other forms of interval are recognized by the parser but rejected by the type-checker.
ppat_constant constructs an Ast.Ppat_constant
Example OCaml
Patterns such as 1, 'a', "true", 1.0, 1l, 1L, 1n
val ppat_alias :
Astlib.Ast_500.Parsetree.pattern ->
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.patternppat_alias constructs an Ast.Ppat_alias
Example OCaml
An alias pattern such as P as 'a
ppat_var constructs an Ast.Ppat_var
Example OCaml
A variable pattern such as x
ppat_any constructs an Ast.Ppat_any
Example OCaml
The pattern _.
Object field
oinherit constructs an Ast.Oinherit
val otag :
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.object_fieldotag constructs an Ast.Otag
Module type declaration
val module_type_declaration :
name:string Astlib.Location.loc ->
type_:Astlib.Ast_500.Parsetree.module_type option ->
Astlib.Ast_500.Parsetree.module_type_declarationmodule_type_declaration constructs an Ast.module_type_declaration
Example OCaml
Values of type module_type_declaration represents:
S = MT,Sfor abstract module type declaration, whenpmtd_typeisNone.
Module type
pmty_alias constructs an Ast.Pmty_alias
Example OCaml
(module M)
val pmty_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.module_typepmty_extension constructs an Ast.Pmty_extension
Example OCaml
[%id]
pmty_typeof constructs an Ast.Pmty_typeof
Example OCaml
module type of ME
val pmty_with :
Astlib.Ast_500.Parsetree.module_type ->
Astlib.Ast_500.Parsetree.with_constraint list ->
Astlib.Ast_500.Parsetree.module_typepmty_with constructs an Ast.Pmty_with
Example OCaml
MT with ...
val pmty_functor :
Astlib.Ast_500.Parsetree.functor_parameter ->
Astlib.Ast_500.Parsetree.module_type ->
Astlib.Ast_500.Parsetree.module_typepmty_functor constructs an Ast.Pmty_functor
Example OCaml
functor(X : MT1) -> MT2
val pmty_signature :
Astlib.Ast_500.Parsetree.signature_item list ->
Astlib.Ast_500.Parsetree.module_typepmty_signature constructs an Ast.Pmty_signature
Example OCaml
sig ... end
pmty_ident constructs an Ast.Pmty_ident
Example OCaml
Pmty_ident(S) represents S
Module substitution
val module_substitution :
name:string Astlib.Location.loc ->
manifest:Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.module_substitutionmodule_substitution constructs an Ast.module_substitution
Example OCaml
Values of type module_substitution represents S := M
Module expr
val pmod_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.module_exprpmod_extension constructs an Ast.Pmod_extension
Example OCaml
[%id]
pmod_unpack constructs an Ast.Pmod_unpack
Example OCaml
(val E)
val pmod_constraint :
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_type ->
Astlib.Ast_500.Parsetree.module_exprpmod_constraint constructs an Ast.Pmod_constraint
Example OCaml
(ME : MT)
val pmod_apply :
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_exprpmod_apply constructs an Ast.Pmod_apply
Example OCaml
ME1(ME2)
val pmod_functor :
Astlib.Ast_500.Parsetree.functor_parameter ->
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_exprpmod_functor constructs an Ast.Pmod_functor
Example OCaml
functor(X : MT1) -> ME
val pmod_structure :
Astlib.Ast_500.Parsetree.structure_item list ->
Astlib.Ast_500.Parsetree.module_exprpmod_structure constructs an Ast.Pmod_structure
Example OCaml
struct ... end
pmod_ident constructs an Ast.Pmod_ident
Example OCaml
X
Module declaration
val module_declaration :
name:string option Astlib.Location.loc ->
type_:Astlib.Ast_500.Parsetree.module_type ->
Astlib.Ast_500.Parsetree.module_declarationmodule_declaration constructs an Ast.module_declaration
Example OCaml
Values of type module_declaration represents S : MT
Module binding
val module_binding :
name:string option Astlib.Location.loc ->
expr:Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_bindingmodule_binding constructs an Ast.module_binding
Example OCaml
Values of type module_binding represents module X = ME
Location
val location :
start:Lexing.position ->
end_:Lexing.position ->
ghost:bool ->
Astlib.Location.tlocation constructs an Ast.location
Letop
val letop :
let_:Astlib.Ast_500.Parsetree.binding_op ->
ands:Astlib.Ast_500.Parsetree.binding_op list ->
body:Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.letopletop constructs an Ast.letop
Label declaration
val label_declaration :
name:string Astlib.Location.loc ->
mutable_:Astlib.Ast_500.Asttypes.mutable_flag ->
type_:Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.label_declarationlabel_declaration constructs an Ast.label_declaration
Example OCaml
{ ...; l: T; ... }whenpld_mutableisImmutable,{ ...; mutable l: T; ... }whenpld_mutableisMutable.
Note: T can be a Ptyp_poly.
Extension constructor
val extension_constructor :
name:string Astlib.Location.loc ->
kind:Astlib.Ast_500.Parsetree.extension_constructor_kind ->
Astlib.Ast_500.Parsetree.extension_constructorextension_constructor constructs an Ast.extension_constructor
Expression
pexp_unreachable constructs an Ast.Pexp_unreachable
Example OCaml
.
val pexp_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.expressionpexp_extension constructs an Ast.Pexp_extension
Example OCaml
[%id]
pexp_letop constructs an Ast.Pexp_letop
Example OCaml
let* P = E0 in E1let* P0 = E00 and* P1 = E01 in E1
val pexp_open :
Astlib.Ast_500.Parsetree.module_expr Astlib.Ast_500.Parsetree.open_infos ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_open constructs an Ast.Pexp_open
Example OCaml
M.(E)let open M in Elet open! M in E
pexp_pack constructs an Ast.Pexp_pack
Example OCaml
(module ME).
(module ME : S) is represented as Pexp_constraint(Pexp_pack ME, Ptyp_package S)
val pexp_newtype :
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_newtype constructs an Ast.Pexp_newtype
Example OCaml
fun (type t) -> E
pexp_object constructs an Ast.Pexp_object
Example OCaml
object ... end
val pexp_poly :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.core_type option ->
Astlib.Ast_500.Parsetree.expressionpexp_poly constructs an Ast.Pexp_poly
Example OCaml
Used for method bodies.
Can only be used as the expression under Cfk_concrete for methods (not values).
pexp_lazy constructs an Ast.Pexp_lazy
Example OCaml
lazy E
pexp_assert constructs an Ast.Pexp_assert
Example OCaml
assert E.
Note: assert false is treated in a special way by the type-checker.
val pexp_letexception :
Astlib.Ast_500.Parsetree.extension_constructor ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_letexception constructs an Ast.Pexp_letexception
Example OCaml
let exception C in E
val pexp_letmodule :
string option Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_letmodule constructs an Ast.Pexp_letmodule
Example OCaml
let module M = ME in E
val pexp_override :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.expression) list ->
Astlib.Ast_500.Parsetree.expressionpexp_override constructs an Ast.Pexp_override
Example OCaml
{< x1 = E1; ...; xn = En >}
val pexp_setinstvar :
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_setinstvar constructs an Ast.Pexp_setinstvar
Example OCaml
x <- 2
pexp_new constructs an Ast.Pexp_new
Example OCaml
new M.c
val pexp_send :
Astlib.Ast_500.Parsetree.expression ->
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expressionpexp_send constructs an Ast.Pexp_send
Example OCaml
E # m
val pexp_coerce :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.core_type option ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.expressionpexp_coerce constructs an Ast.Pexp_coerce
Example OCaml
Pexp_coerce(E, from, T) represents
(E :> T)whenfromisNone,(E : T0 :> T)whenfromisSome T0.
val pexp_constraint :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.expressionpexp_constraint constructs an Ast.Pexp_constraint
Example OCaml
(E : T)
val pexp_for :
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Asttypes.direction_flag ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_for constructs an Ast.Pexp_for
Example OCaml
Pexp_for(i, E1, E2, direction, E3) represents:
for i = E1 to E2 do E3 donewhendirectionisUptofor i = E1 downto E2 do E3 donewhendirectionisDownto
val pexp_while :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_while constructs an Ast.Pexp_while
Example OCaml
while E1 do E2 done
val pexp_sequence :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_sequence constructs an Ast.Pexp_sequence
Example OCaml
E1; E2
val pexp_ifthenelse :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expressionpexp_ifthenelse constructs an Ast.Pexp_ifthenelse
Example OCaml
if E1 then E2 else E3
pexp_array constructs an Ast.Pexp_array
Example OCaml
[| E1; ...; En |]
val pexp_setfield :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_setfield constructs an Ast.Pexp_setfield
Example OCaml
E1.l <- E2
val pexp_field :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expressionpexp_field constructs an Ast.Pexp_field
Example OCaml
E.l
val pexp_record :
(Astlib.Longident.t Astlib.Location.loc * Astlib.Ast_500.Parsetree.expression)
list ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expressionpexp_record constructs an Ast.Pexp_record
Example OCaml
Pexp_record([(l1,P1) ; ... ; (ln,Pn)], exp0) represents
{ l1=P1; ...; ln=Pn }whenexp0isNone{ E0 with l1=P1; ...; ln=Pn }whenexp0isSome E0
Invariant: n > 0
val pexp_variant :
string ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expressionpexp_variant constructs an Ast.Pexp_variant
Example OCaml
Pexp_variant(`A, exp) represents
`AwhenexpisNone`A EwhenexpisSome E
val pexp_construct :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expressionpexp_construct constructs an Ast.Pexp_construct
Example OCaml
Pexp_construct(C, exp) represents:
CwhenexpisNone,C EwhenexpisSome E,C (E1, ..., En)whenexpisSome (Pexp_tuple[E1;...;En])
pexp_tuple constructs an Ast.Pexp_tuple
Example OCaml
Expressions (E1, ..., En)
Invariant: n >= 2
val pexp_try :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.case list ->
Astlib.Ast_500.Parsetree.expressionpexp_try constructs an Ast.Pexp_try
Example OCaml
try E0 with P1 -> E1 | ... | Pn -> En
val pexp_match :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.case list ->
Astlib.Ast_500.Parsetree.expressionpexp_match constructs an Ast.Pexp_match
Example OCaml
match E0 with P1 -> E1 | ... | Pn -> En
val pexp_apply :
Astlib.Ast_500.Parsetree.expression ->
(Astlib.Ast_500.Asttypes.arg_label * Astlib.Ast_500.Parsetree.expression)
list ->
Astlib.Ast_500.Parsetree.expressionpexp_apply constructs an Ast.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_fun :
Astlib.Ast_500.Asttypes.arg_label ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_fun constructs an Ast.Pexp_fun
Example OCaml
Pexp_fun(lbl, exp0, P, E1) represents:
fun P -> E1whenlblisNolabelandexp0isNonefun ~l:P -> E1whenlblisLabelled landexp0isNonefun ?l:P -> E1whenlblisOptional landexp0isNonefun ?l:(P = E0) -> E1whenlblisOptional landexp0isSome E0
Notes:
- If
E0is provided, onlyOptionalis allowed. fun P1 P2 .. Pn -> E1is represented as nestedPexp_fun.let f P = Eis represented usingPexp_fun.
pexp_function constructs an Ast.Pexp_function
Example OCaml
function P1 -> E1 | ... | Pn -> En
val pexp_let :
Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.value_binding list ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionpexp_let constructs an Ast.Pexp_let
Example OCaml
Pexp_let(flag, [(P1,E1) ; ... ; (Pn,En)], E) represents:
let P1 = E1 and ... and Pn = EN in EwhenflagisNonrecursive,let rec P1 = E1 and ... and Pn = EN in EwhenflagisRecursive.
pexp_constant constructs an Ast.Pexp_constant
Example OCaml
Expressions constant such as 1, 'a', "true", 1.0, 1l, 1L, 1n
pexp_ident constructs an Ast.Pexp_ident
Example OCaml
Identifiers such as x and M.x
Directive argument
pdir_bool constructs an Ast.Pdir_bool
pdir_ident constructs an Ast.Pdir_ident
pdir_int constructs an Ast.Pdir_int
pdir_string constructs an Ast.Pdir_string
Core type
val ptyp_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.core_typeptyp_extension constructs an Ast.Ptyp_extension
Example OCaml
[%id].
val ptyp_package :
(Astlib.Longident.t Astlib.Location.loc
* (Astlib.Longident.t Astlib.Location.loc
* Astlib.Ast_500.Parsetree.core_type)
list) ->
Astlib.Ast_500.Parsetree.core_typeptyp_package constructs an Ast.Ptyp_package
Example OCaml
(module S).
val ptyp_poly :
string Astlib.Location.loc list ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.core_typeptyp_poly constructs an Ast.Ptyp_poly
Example OCaml
'a1 ... 'an. T
Can only appear in the following context:
- As the
core_typeof aPpat_constraintnode corresponding to a constraint on a let-binding:
let x : 'a1 ... 'an. T = e ...- Under
Cfk_virtualfor methods (not values).
- As the
core_typeof aPctf_methodnode.
- As the
core_typeof aPexp_polynode.
- As the
pld_typefield of alabel_declaration.
- As a
core_typeof aPtyp_objectnode.
- As the
pval_typefield of avalue_description.
val ptyp_variant :
Astlib.Ast_500.Parsetree.row_field list ->
Astlib.Ast_500.Asttypes.closed_flag ->
string list option ->
Astlib.Ast_500.Parsetree.core_typeptyp_variant constructs an Ast.Ptyp_variant
Example OCaml
Ptyp_variant([`A;`B], flag, labels) represents:
[ `A|`B ]whenflagisClosed, andlabelsisNone,[> `A|`B ]whenflagisOpen, andlabelsisNone,[< `A|`B ]whenflagisClosed, andlabelsisSome [],[< `A|`B > `X `Y ]whenflagisClosed, andlabelsisSome ["X";"Y"].
ptyp_alias constructs an Ast.Ptyp_alias
Example OCaml
T as 'a.
val ptyp_class :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.core_typeptyp_class constructs an Ast.Ptyp_class
Example OCaml
Ptyp_class(tconstr, l) represents:
#tconstrwhenl=[],T #tconstrwhenl=[T],(T1, ..., Tn) #tconstrwhenl=[T1 ; ... ; Tn].
val ptyp_object :
Astlib.Ast_500.Parsetree.object_field list ->
Astlib.Ast_500.Asttypes.closed_flag ->
Astlib.Ast_500.Parsetree.core_typeptyp_object constructs an Ast.Ptyp_object
Example OCaml
Ptyp_object([ l1:T1; ...; ln:Tn ], flag) represents:
< l1:T1; ...; ln:Tn >whenflagisClosed,< l1:T1; ...; ln:Tn; .. >whenflagisOpen.
val ptyp_constr :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.core_typeptyp_constr constructs an Ast.Ptyp_constr
Example OCaml
Ptyp_constr(lident, l) represents:
tconstrwhenl=[],T tconstrwhenl=[T],(T1, ..., Tn) tconstrwhenl=[T1 ; ... ; Tn].
ptyp_tuple constructs an Ast.Ptyp_tuple
Example OCaml
Ptyp_tuple([T1 ; ... ; Tn]) represents a product type T1 * ... * Tn.
Invariant: n >= 2.
val ptyp_arrow :
Astlib.Ast_500.Asttypes.arg_label ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.core_typeptyp_arrow constructs an Ast.Ptyp_arrow
Example OCaml
Ptyp_arrow(lbl, T1, T2) represents:
T1 -> T2whenlblisNolabel,~l:T1 -> T2whenlblisLabelled,?l:T1 -> T2whenlblisOptional.
ptyp_var constructs an Ast.Ptyp_var
Example OCaml
A type variable such as 'a
Constructor declaration
Class type field
val pctf_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_type_fieldpctf_extension constructs an Ast.Pctf_extension
Example OCaml
[%%id]
val pctf_attribute :
Astlib.Ast_500.Parsetree.attribute ->
Astlib.Ast_500.Parsetree.class_type_fieldpctf_attribute constructs an Ast.Pctf_attribute
Example OCaml
[@@@id]
val pctf_constraint :
(Astlib.Ast_500.Parsetree.core_type * Astlib.Ast_500.Parsetree.core_type) ->
Astlib.Ast_500.Parsetree.class_type_fieldpctf_constraint constructs an Ast.Pctf_constraint
Example OCaml
constraint T1 = T2
val pctf_method :
(string Astlib.Location.loc
* Astlib.Ast_500.Asttypes.private_flag
* Astlib.Ast_500.Asttypes.virtual_flag
* Astlib.Ast_500.Parsetree.core_type) ->
Astlib.Ast_500.Parsetree.class_type_fieldpctf_method constructs an Ast.Pctf_method
Example OCaml
method x: T
Note: T can be a Ptyp_poly.
val pctf_val :
(string Astlib.Location.loc
* Astlib.Ast_500.Asttypes.mutable_flag
* Astlib.Ast_500.Asttypes.virtual_flag
* Astlib.Ast_500.Parsetree.core_type) ->
Astlib.Ast_500.Parsetree.class_type_fieldpctf_val constructs an Ast.Pctf_val
Example OCaml
val x: T
pctf_inherit constructs an Ast.Pctf_inherit
Example OCaml
inherit CT
Class type
val pcty_open :
Astlib.Longident.t Astlib.Location.loc Astlib.Ast_500.Parsetree.open_infos ->
Astlib.Ast_500.Parsetree.class_type ->
Astlib.Ast_500.Parsetree.class_typepcty_open constructs an Ast.Pcty_open
Example OCaml
let open M in CT
val pcty_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_typepcty_extension constructs an Ast.Pcty_extension
Example OCaml
%id
val pcty_arrow :
Astlib.Ast_500.Asttypes.arg_label ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.class_type ->
Astlib.Ast_500.Parsetree.class_typepcty_arrow constructs an Ast.Pcty_arrow
Example OCaml
Pcty_arrow(lbl, T, CT) represents:
T -> CTwhenlblisNolabel,~l:T -> CTwhenlblisLabelled l,?l:T -> CTwhenlblisOptional l.
val pcty_signature :
Astlib.Ast_500.Parsetree.class_signature ->
Astlib.Ast_500.Parsetree.class_typepcty_signature constructs an Ast.Pcty_signature
Example OCaml
object ... end
val pcty_constr :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.class_typepcty_constr constructs an Ast.Pcty_constr
Example OCaml
c['a1, ..., 'an] c
Class structure
val class_structure :
self:Astlib.Ast_500.Parsetree.pattern ->
fields:Astlib.Ast_500.Parsetree.class_field list ->
Astlib.Ast_500.Parsetree.class_structureclass_structure constructs an Ast.class_structure
Example OCaml
Values of type class_structure represents:
object(selfpat) ... endobject ... endwhenpcstr_selfisPpat_any
Class signature
val class_signature :
self:Astlib.Ast_500.Parsetree.core_type ->
fields:Astlib.Ast_500.Parsetree.class_type_field list ->
Astlib.Ast_500.Parsetree.class_signatureclass_signature constructs an Ast.class_signature
Example OCaml
Values of type class_signature represents:
object('selfpat) ... endobject ... endwhenpcsig_selfisPtyp_any
Class field
val pcf_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_fieldpcf_extension constructs an Ast.Pcf_extension
Example OCaml
[%%id]
pcf_attribute constructs an Ast.Pcf_attribute
Example OCaml
[@@@id]
pcf_initializer constructs an Ast.Pcf_initializer
Example OCaml
initializer E
val pcf_constraint :
(Astlib.Ast_500.Parsetree.core_type * Astlib.Ast_500.Parsetree.core_type) ->
Astlib.Ast_500.Parsetree.class_fieldpcf_constraint constructs an Ast.Pcf_constraint
Example OCaml
constraint T1 = T2
val pcf_method :
(string Astlib.Location.loc
* Astlib.Ast_500.Asttypes.private_flag
* Astlib.Ast_500.Parsetree.class_field_kind) ->
Astlib.Ast_500.Parsetree.class_fieldpcf_method constructs an Ast.Pcf_method
Example OCaml
method x = E(Ecan be aPexp_poly)method virtual x: T(Tcan be aPtyp_poly)
val pcf_val :
(string Astlib.Location.loc
* Astlib.Ast_500.Asttypes.mutable_flag
* Astlib.Ast_500.Parsetree.class_field_kind) ->
Astlib.Ast_500.Parsetree.class_fieldpcf_val constructs an Ast.Pcf_val
Example OCaml
Pcf_val(x,flag, kind) represents:
val x = EwhenflagisImmutableandkindisCfk_concrete(Fresh, E)val virtual x: TwhenflagisImmutableandkindisCfk_virtual(T)val mutable x = EwhenflagisMutableandkindisCfk_concrete(Fresh, E)val mutable virtual x: TwhenflagisMutableandkindisCfk_virtual(T)
val pcf_inherit :
Astlib.Ast_500.Asttypes.override_flag ->
Astlib.Ast_500.Parsetree.class_expr ->
string Astlib.Location.loc option ->
Astlib.Ast_500.Parsetree.class_fieldpcf_inherit constructs an Ast.Pcf_inherit
Example OCaml
Pcf_inherit(flag, CE, s) represents:
inherit CEwhenflagisFreshandsisNone,inherit CE as xwhenflagisFreshandsisSome x,inherit! CEwhenflagisOverrideandsisNone,inherit! CE as xwhenflagisOverrideandsisSome x
Class expr
val pcl_open :
Astlib.Longident.t Astlib.Location.loc Astlib.Ast_500.Parsetree.open_infos ->
Astlib.Ast_500.Parsetree.class_expr ->
Astlib.Ast_500.Parsetree.class_exprpcl_open constructs an Ast.Pcl_open
Example OCaml
let open M in CE
val pcl_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_exprpcl_extension constructs an Ast.Pcl_extension
Example OCaml
[%id]
val pcl_constraint :
Astlib.Ast_500.Parsetree.class_expr ->
Astlib.Ast_500.Parsetree.class_type ->
Astlib.Ast_500.Parsetree.class_exprpcl_constraint constructs an Ast.Pcl_constraint
Example OCaml
(CE : CT)
val pcl_let :
Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.value_binding list ->
Astlib.Ast_500.Parsetree.class_expr ->
Astlib.Ast_500.Parsetree.class_exprpcl_let constructs an Ast.Pcl_let
Example OCaml
Pcl_let(rec, [(P1, E1); ... ; (Pn, En)], CE) represents:
let P1 = E1 and ... and Pn = EN in CEwhenrecisNonrecursive,let rec P1 = E1 and ... and Pn = EN in CEwhenrecisRecursive.
val pcl_apply :
Astlib.Ast_500.Parsetree.class_expr ->
(Astlib.Ast_500.Asttypes.arg_label * Astlib.Ast_500.Parsetree.expression)
list ->
Astlib.Ast_500.Parsetree.class_exprpcl_apply constructs an Ast.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 :
Astlib.Ast_500.Asttypes.arg_label ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.class_expr ->
Astlib.Ast_500.Parsetree.class_exprpcl_fun constructs an Ast.Pcl_fun
Example OCaml
Pcl_fun(lbl, exp0, P, CE) represents:
fun P -> CEwhenlblisNolabelandexp0isNone,fun ~l:P -> CEwhenlblisLabelled landexp0isNone,fun ?l:P -> CEwhenlblisOptional landexp0isNone,fun ?l:(P = E0) -> CEwhenlblisOptional landexp0isSome E0.
pcl_structure constructs an Ast.Pcl_structure
Example OCaml
object ... end
val pcl_constr :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.class_exprpcl_constr constructs an Ast.Pcl_constr
Example OCaml
c and ['a1, ..., 'an] c
Case
Binding op
val binding_op :
op:string Astlib.Location.loc ->
pat:Astlib.Ast_500.Parsetree.pattern ->
exp:Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.binding_opbinding_op constructs an Ast.binding_op
Attribute
val attribute :
name:string Astlib.Location.loc ->
payload:Astlib.Ast_500.Parsetree.payload ->
Astlib.Ast_500.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.
'a open infos
val open_infos :
expr:'a ->
override:Astlib.Ast_500.Asttypes.override_flag ->
'a Astlib.Ast_500.Parsetree.open_infosopen_infos constructs an Ast.'aopen_infos
Example OCaml
Values of type 'a open_infos represents:
open! Xwhenpopen_overrideisOverride(silences the "used identifier shadowing" warning)open Xwhenpopen_overrideisFresh
'a include infos
include_infos constructs an Ast.'ainclude_infos
'a class infos
val class_infos :
virt:Astlib.Ast_500.Asttypes.virtual_flag ->
params:
(Astlib.Ast_500.Parsetree.core_type
* (Astlib.Ast_500.Asttypes.variance * Astlib.Ast_500.Asttypes.injectivity))
list ->
name:string Astlib.Location.loc ->
expr:'a ->
'a Astlib.Ast_500.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.
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 eapply :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expressionSame as pexp_apply but without labels
val elist_tail :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expressionelist_tail ~loc [expr1; expr2; expr3] expr_tail produces the expression expr1::expr2::expr3::expr_tail.
elist ~loc [expr1; expr2; expr3] produces the list litteral expression [expr1; expr2; expr3].
val plist_tail :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.patternplist_tail ~loc [pat1; pat2; pat3] pat_tail produces the pattern pat1::pat2::pat3::pat_tail.
plist ~loc [pat1; pat2; pat3] produces the list pattern [pat1; pat2; pat3].
val pstr_value_list :
loc:Ppxlib.Location.t ->
Ppxlib_ast.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.value_binding list ->
Astlib.Ast_500.Parsetree.structure_item listpstr_value_list ~loc rf vbs = pstr_value ~loc rf vbs if vbs <> [], [] otherwise.
val nonrec_type_declaration :
name:string Ppxlib.Loc.t ->
params:
(Astlib.Ast_500.Parsetree.core_type * Ppxlib_ast.Asttypes.variance) list ->
cstrs:
(Astlib.Ast_500.Parsetree.core_type
* Astlib.Ast_500.Parsetree.core_type
* Ppxlib.Location.t)
list ->
kind:Astlib.Ast_500.Parsetree.type_kind ->
private_:Ppxlib_ast.Asttypes.private_flag ->
manifest:Astlib.Ast_500.Parsetree.core_type option ->
Astlib.Ast_500.Parsetree.type_declarationval unapplied_type_constr_conv :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Astlib.Ast_500.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 :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expressionTries 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.
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.
- Value description
- Value binding
- Type extension
- Type exception
- Type declaration
- Toplevel directive
- Structure item
- Signature item
- Row field
- Position
- Pattern
- Object field
- Module type declaration
- Module type
- Module substitution
- Module expr
- Module declaration
- Module binding
- Location
- Letop
- Label declaration
- Extension constructor
- Expression
- Directive argument
- Core type
- Constructor declaration
- Class type field
- Class type
- Class structure
- Class signature
- Class field
- Class expr
- Case
- Binding op
- Attribute
- 'a open infos
- 'a include infos
- 'a class infos