package ppx_repr
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d9bd2fe51c2eb6fca27731034c46f9a77dc8bc9fb7b76216f8a571603d6e7d74
sha512=7b4ad2cbcd92f6647a1abe1d82557f02e4955c5f37f02089388c752e23b865af0f55fdd6bc63a1d2a00962baf96ccd99ccd9b8ecd8898dcc2a0cd17302f067c3
doc/ppx_repr.lib/Ppx_repr_lib/Algebraic/Located/argument-1-S/index.html
Parameter Located.S
module Located : sig ... end
val loc : Ppxlib.Location.t
Value description
val value_description :
name:string Astlib.Location.loc ->
type_:Astlib.Ast_500.Parsetree.core_type ->
prim:string list ->
Astlib.Ast_500.Parsetree.value_description
value_description
constructs an Ast.value_description
Example OCaml
Values of type value_description
represents:
val x: T
, whenpval_prim
is[]
external x: T = "s1" ... "sn"
whenpval_prim
is["s1";..."sn"]
Value binding
val value_binding :
pat:Astlib.Ast_500.Parsetree.pattern ->
expr:Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.value_binding
value_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_extension
type_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_exception
type_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_declaration
type_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
whentype_kind
isPtype_abstract
, andmanifest
isNone
,type t = T0
whentype_kind
isPtype_abstract
, andmanifest
isSome T0
,type t = C of T | ...
whentype_kind
isPtype_variant
, andmanifest
isNone
,type t = T0 = C of T | ...
whentype_kind
isPtype_variant
, andmanifest
isSome T0
,type t = {l: T; ...}
whentype_kind
isPtype_record
, andmanifest
isNone
,type t = T0 = {l : T; ...}
whentype_kind
isPtype_record
, andmanifest
isSome T0
,type t = ..
whentype_kind
isPtype_open
, andmanifest
isNone
.
Toplevel directive
val toplevel_directive :
name:string Astlib.Location.loc ->
arg:Astlib.Ast_500.Parsetree.directive_argument option ->
Astlib.Ast_500.Parsetree.toplevel_directive
toplevel_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_item
pstr_extension
constructs an Ast.Pstr_extension
Example OCaml
[%%id]
val pstr_attribute :
Astlib.Ast_500.Parsetree.attribute ->
Astlib.Ast_500.Parsetree.structure_item
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_item
pstr_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_item
pstr_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_item
pstr_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_item
pstr_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_item
pstr_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_item
pstr_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_item
pstr_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_item
pstr_exception
constructs an Ast.Pstr_exception
Example OCaml
exception C of T
exception C = M.X
val pstr_typext :
Astlib.Ast_500.Parsetree.type_extension ->
Astlib.Ast_500.Parsetree.structure_item
pstr_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_item
pstr_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_item
pstr_primitive
constructs an Ast.Pstr_primitive
Example OCaml
val x: T
external 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_item
pstr_value
constructs an Ast.Pstr_value
Example OCaml
Pstr_value(rec, [(P1, E1 ; ... ; (Pn, En))])
represents:
let P1 = E1 and ... and Pn = EN
whenrec
isNonrecursive
,let rec P1 = E1 and ... and Pn = EN
whenrec
isRecursive
.
val pstr_eval :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.attribute list ->
Astlib.Ast_500.Parsetree.structure_item
pstr_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_item
psig_extension
constructs an Ast.Psig_extension
Example OCaml
[%%id]
val psig_attribute :
Astlib.Ast_500.Parsetree.attribute ->
Astlib.Ast_500.Parsetree.signature_item
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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_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_item
psig_value
constructs an Ast.Psig_value
Example OCaml
val x: T
external x: T = "s1" ... "sn"
Row field
val rinherit :
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.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_field
rtag
constructs an Ast.Rtag
Example OCaml
Rtag(`A, b, l)
represents:
`A
whenb
istrue
andl
is[]
,`A of T
whenb
isfalse
andl
is[T]
,`A of T1 & .. & Tn
whenb
isfalse
andl
is[T1;...Tn]
,`A of & T1 & .. & Tn
whenb
istrue
andl
is[T1;...Tn]
.
- The
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
val position :
fname:string ->
lnum:int ->
bol:int ->
cnum:int ->
Lexing.position
position
constructs an Ast.position
Pattern
val ppat_open :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.pattern
ppat_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.pattern
ppat_extension
constructs an Ast.Ppat_extension
Example OCaml
Pattern [%id]
val ppat_exception :
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.pattern
ppat_exception
constructs an Ast.Ppat_exception
Example OCaml
Pattern exception P
val ppat_unpack :
string option Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.pattern
ppat_unpack
constructs an Ast.Ppat_unpack
Example OCaml
Ppat_unpack(s)
represents:
(module P)
whens
isSome "P"
(module _)
whens
isNone
Note: (module P : S)
is represented as Ppat_constraint(Ppat_unpack(Some "P"), Ptyp_package S)
val ppat_lazy :
Astlib.Ast_500.Parsetree.pattern ->
Astlib.Ast_500.Parsetree.pattern
ppat_lazy
constructs an Ast.Ppat_lazy
Example OCaml
Pattern lazy P
val ppat_type :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.pattern
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.pattern
ppat_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.pattern
ppat_or
constructs an Ast.Ppat_or
Example OCaml
Pattern P1 | P2
val ppat_array :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.pattern
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.pattern
ppat_record
constructs an Ast.Ppat_record
Example OCaml
Ppat_record([(l1, P1) ; ... ; (ln, Pn)], flag)
represents:
{ l1=P1; ...; ln=Pn }
whenflag
isClosed
{ l1=P1; ...; ln=Pn; _}
whenflag
isOpen
Invariant: n > 0
val ppat_variant :
string ->
Astlib.Ast_500.Parsetree.pattern option ->
Astlib.Ast_500.Parsetree.pattern
ppat_variant
constructs an Ast.Ppat_variant
Example OCaml
Ppat_variant(`A, pat)
represents:
`A
whenpat
isNone
,`A P
whenpat
isSome P
val ppat_tuple :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.pattern
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.pattern
ppat_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.
val ppat_constant :
Astlib.Ast_500.Parsetree.constant ->
Astlib.Ast_500.Parsetree.pattern
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.pattern
ppat_alias
constructs an Ast.Ppat_alias
Example OCaml
An alias pattern such as P as 'a
val ppat_var : string Astlib.Location.loc -> Astlib.Ast_500.Parsetree.pattern
ppat_var
constructs an Ast.Ppat_var
Example OCaml
A variable pattern such as x
val ppat_any : Astlib.Ast_500.Parsetree.pattern
ppat_any
constructs an Ast.Ppat_any
Example OCaml
The pattern _
.
Object field
val oinherit :
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.object_field
oinherit
constructs an Ast.Oinherit
val otag :
string Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.object_field
otag
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_declaration
module_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, whenpmtd_type
isNone
.
Module type
val pmty_alias :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.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_type
pmty_extension
constructs an Ast.Pmty_extension
Example OCaml
[%id]
val pmty_typeof :
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.module_type
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_type
pmty_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_type
pmty_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_type
pmty_signature
constructs an Ast.Pmty_signature
Example OCaml
sig ... end
val pmty_ident :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.module_type
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_substitution
module_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_expr
pmod_extension
constructs an Ast.Pmod_extension
Example OCaml
[%id]
val pmod_unpack :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.module_expr
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_expr
pmod_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_expr
pmod_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_expr
pmod_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_expr
pmod_structure
constructs an Ast.Pmod_structure
Example OCaml
struct ... end
val pmod_ident :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.module_expr
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_declaration
module_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_binding
module_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.t
location
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.letop
letop
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_declaration
label_declaration
constructs an Ast.label_declaration
Example OCaml
{ ...; l: T; ... }
whenpld_mutable
isImmutable
,{ ...; mutable l: T; ... }
whenpld_mutable
isMutable
.
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_constructor
extension_constructor
constructs an Ast.extension_constructor
Expression
val pexp_unreachable : Astlib.Ast_500.Parsetree.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.expression
pexp_extension
constructs an Ast.Pexp_extension
Example OCaml
[%id]
val pexp_letop :
Astlib.Ast_500.Parsetree.letop ->
Astlib.Ast_500.Parsetree.expression
pexp_letop
constructs an Ast.Pexp_letop
Example OCaml
let* P = E0 in E1
let* 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.expression
pexp_open
constructs an Ast.Pexp_open
Example OCaml
M.(E)
let open M in E
let open! M in E
val pexp_pack :
Astlib.Ast_500.Parsetree.module_expr ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_newtype
constructs an Ast.Pexp_newtype
Example OCaml
fun (type t) -> E
val pexp_object :
Astlib.Ast_500.Parsetree.class_structure ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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).
val pexp_lazy :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
pexp_lazy
constructs an Ast.Pexp_lazy
Example OCaml
lazy E
val pexp_assert :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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.expression
pexp_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.expression
pexp_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.expression
pexp_setinstvar
constructs an Ast.Pexp_setinstvar
Example OCaml
x <- 2
val pexp_new :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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.expression
pexp_coerce
constructs an Ast.Pexp_coerce
Example OCaml
Pexp_coerce(E, from, T)
represents
(E :> T)
whenfrom
isNone
,(E : T0 :> T)
whenfrom
isSome T0
.
val pexp_constraint :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.core_type ->
Astlib.Ast_500.Parsetree.expression
pexp_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.expression
pexp_for
constructs an Ast.Pexp_for
Example OCaml
Pexp_for(i, E1, E2, direction, E3)
represents:
for i = E1 to E2 do E3 done
whendirection
isUpto
for i = E1 downto E2 do E3 done
whendirection
isDownto
val pexp_while :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
pexp_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.expression
pexp_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.expression
pexp_ifthenelse
constructs an Ast.Pexp_ifthenelse
Example OCaml
if E1 then E2 else E3
val pexp_array :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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.expression
pexp_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.expression
pexp_record
constructs an Ast.Pexp_record
Example OCaml
Pexp_record([(l1,P1) ; ... ; (ln,Pn)], exp0)
represents
{ l1=P1; ...; ln=Pn }
whenexp0
isNone
{ E0 with l1=P1; ...; ln=Pn }
whenexp0
isSome E0
Invariant: n > 0
val pexp_variant :
string ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expression
pexp_variant
constructs an Ast.Pexp_variant
Example OCaml
Pexp_variant(`A, exp)
represents
`A
whenexp
isNone
`A E
whenexp
isSome E
val pexp_construct :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expression
pexp_construct
constructs an Ast.Pexp_construct
Example OCaml
Pexp_construct(C, exp)
represents:
C
whenexp
isNone
,C E
whenexp
isSome E
,C (E1, ..., En)
whenexp
isSome (Pexp_tuple[E1;...;En])
val pexp_tuple :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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.expression
pexp_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.expression
pexp_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.expression
pexp_fun
constructs an Ast.Pexp_fun
Example OCaml
Pexp_fun(lbl, exp0, P, E1)
represents:
fun P -> E1
whenlbl
isNolabel
andexp0
isNone
fun ~l:P -> E1
whenlbl
isLabelled l
andexp0
isNone
fun ?l:P -> E1
whenlbl
isOptional l
andexp0
isNone
fun ?l:(P = E0) -> E1
whenlbl
isOptional l
andexp0
isSome E0
Notes:
- If
E0
is provided, onlyOptional
is allowed. fun P1 P2 .. Pn -> E1
is represented as nestedPexp_fun
.let f P = E
is represented usingPexp_fun
.
val pexp_function :
Astlib.Ast_500.Parsetree.case list ->
Astlib.Ast_500.Parsetree.expression
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.expression
pexp_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 E
whenflag
isNonrecursive
,let rec P1 = E1 and ... and Pn = EN in E
whenflag
isRecursive
.
val pexp_constant :
Astlib.Ast_500.Parsetree.constant ->
Astlib.Ast_500.Parsetree.expression
pexp_constant
constructs an Ast.Pexp_constant
Example OCaml
Expressions constant such as 1
, 'a'
, "true"
, 1.0
, 1l
, 1L
, 1n
val pexp_ident :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.expression
pexp_ident
constructs an Ast.Pexp_ident
Example OCaml
Identifiers such as x
and M.x
Directive argument
val pdir_bool : bool -> Astlib.Ast_500.Parsetree.directive_argument
pdir_bool
constructs an Ast.Pdir_bool
val pdir_ident :
Astlib.Longident.t ->
Astlib.Ast_500.Parsetree.directive_argument
pdir_ident
constructs an Ast.Pdir_ident
val pdir_int :
string ->
char option ->
Astlib.Ast_500.Parsetree.directive_argument
pdir_int
constructs an Ast.Pdir_int
val pdir_string : string -> Astlib.Ast_500.Parsetree.directive_argument
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_type
ptyp_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_type
ptyp_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_type
ptyp_poly
constructs an Ast.Ptyp_poly
Example OCaml
'a1 ... 'an. T
Can only appear in the following context:
- As the
core_type
of aPpat_constraint
node corresponding to a constraint on a let-binding:
let x : 'a1 ... 'an. T = e ...
- Under
Cfk_virtual
for methods (not values).
- As the
core_type
of aPctf_method
node.
- As the
core_type
of aPexp_poly
node.
- As the
pld_type
field of alabel_declaration
.
- As a
core_type
of aPtyp_object
node.
- As the
pval_type
field 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_type
ptyp_variant
constructs an Ast.Ptyp_variant
Example OCaml
Ptyp_variant([`A;`B], flag, labels)
represents:
[ `A|`B ]
whenflag
isClosed
, andlabels
isNone
,[> `A|`B ]
whenflag
isOpen
, andlabels
isNone
,[< `A|`B ]
whenflag
isClosed
, andlabels
isSome []
,[< `A|`B > `X `Y ]
whenflag
isClosed
, andlabels
isSome ["X";"Y"]
.
val ptyp_alias :
Astlib.Ast_500.Parsetree.core_type ->
string ->
Astlib.Ast_500.Parsetree.core_type
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_type
ptyp_class
constructs an Ast.Ptyp_class
Example OCaml
Ptyp_class(tconstr, l)
represents:
#tconstr
whenl=[]
,T #tconstr
whenl=[T]
,(T1, ..., Tn) #tconstr
whenl=[T1 ; ... ; Tn]
.
val ptyp_object :
Astlib.Ast_500.Parsetree.object_field list ->
Astlib.Ast_500.Asttypes.closed_flag ->
Astlib.Ast_500.Parsetree.core_type
ptyp_object
constructs an Ast.Ptyp_object
Example OCaml
Ptyp_object([ l1:T1; ...; ln:Tn ], flag)
represents:
< l1:T1; ...; ln:Tn >
whenflag
isClosed
,< l1:T1; ...; ln:Tn; .. >
whenflag
isOpen
.
val ptyp_constr :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.core_type
ptyp_constr
constructs an Ast.Ptyp_constr
Example OCaml
Ptyp_constr(lident, l)
represents:
tconstr
whenl=[]
,T tconstr
whenl=[T]
,(T1, ..., Tn) tconstr
whenl=[T1 ; ... ; Tn]
.
val ptyp_tuple :
Astlib.Ast_500.Parsetree.core_type list ->
Astlib.Ast_500.Parsetree.core_type
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_type
ptyp_arrow
constructs an Ast.Ptyp_arrow
Example OCaml
Ptyp_arrow(lbl, T1, T2)
represents:
T1 -> T2
whenlbl
isNolabel
,~l:T1 -> T2
whenlbl
isLabelled
,?l:T1 -> T2
whenlbl
isOptional
.
val ptyp_var : string -> Astlib.Ast_500.Parsetree.core_type
ptyp_var
constructs an Ast.Ptyp_var
Example OCaml
A type variable such as 'a
val ptyp_any : Astlib.Ast_500.Parsetree.core_type
ptyp_any
constructs an Ast.Ptyp_any
Example OCaml
_
Constructor declaration
Class type field
val pctf_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_type_field
pctf_extension
constructs an Ast.Pctf_extension
Example OCaml
[%%id]
val pctf_attribute :
Astlib.Ast_500.Parsetree.attribute ->
Astlib.Ast_500.Parsetree.class_type_field
pctf_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_field
pctf_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_field
pctf_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_field
pctf_val
constructs an Ast.Pctf_val
Example OCaml
val x: T
val pctf_inherit :
Astlib.Ast_500.Parsetree.class_type ->
Astlib.Ast_500.Parsetree.class_type_field
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_type
pcty_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_type
pcty_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_type
pcty_arrow
constructs an Ast.Pcty_arrow
Example OCaml
Pcty_arrow(lbl, T, CT)
represents:
T -> CT
whenlbl
isNolabel
,~l:T -> CT
whenlbl
isLabelled l
,?l:T -> CT
whenlbl
isOptional l
.
val pcty_signature :
Astlib.Ast_500.Parsetree.class_signature ->
Astlib.Ast_500.Parsetree.class_type
pcty_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_type
pcty_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_structure
class_structure
constructs an Ast.class_structure
Example OCaml
Values of type class_structure
represents:
object(selfpat) ... end
object ... end
whenpcstr_self
isPpat_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_signature
class_signature
constructs an Ast.class_signature
Example OCaml
Values of type class_signature
represents:
object('selfpat) ... end
object ... end
whenpcsig_self
isPtyp_any
Class field
val pcf_extension :
(string Astlib.Location.loc * Astlib.Ast_500.Parsetree.payload) ->
Astlib.Ast_500.Parsetree.class_field
pcf_extension
constructs an Ast.Pcf_extension
Example OCaml
[%%id]
val pcf_attribute :
Astlib.Ast_500.Parsetree.attribute ->
Astlib.Ast_500.Parsetree.class_field
pcf_attribute
constructs an Ast.Pcf_attribute
Example OCaml
[@@@id]
val pcf_initializer :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.class_field
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_field
pcf_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_field
pcf_method
constructs an Ast.Pcf_method
Example OCaml
method x = E
(E
can be aPexp_poly
)method virtual x: T
(T
can 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_field
pcf_val
constructs an Ast.Pcf_val
Example OCaml
Pcf_val(x,flag, kind)
represents:
val x = E
whenflag
isImmutable
andkind
isCfk_concrete(Fresh, E)
val virtual x: T
whenflag
isImmutable
andkind
isCfk_virtual(T)
val mutable x = E
whenflag
isMutable
andkind
isCfk_concrete(Fresh, E)
val mutable virtual x: T
whenflag
isMutable
andkind
isCfk_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_field
pcf_inherit
constructs an Ast.Pcf_inherit
Example OCaml
Pcf_inherit(flag, CE, s)
represents:
inherit CE
whenflag
isFresh
ands
isNone
,inherit CE as x
whenflag
isFresh
ands
isSome x
,inherit! CE
whenflag
isOverride
ands
isNone
,inherit! CE as x
whenflag
isOverride
ands
isSome 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_expr
pcl_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_expr
pcl_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_expr
pcl_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_expr
pcl_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 CE
whenrec
isNonrecursive
,let rec P1 = E1 and ... and Pn = EN in CE
whenrec
isRecursive
.
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_expr
pcl_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_expr
pcl_fun
constructs an Ast.Pcl_fun
Example OCaml
Pcl_fun(lbl, exp0, P, CE)
represents:
fun P -> CE
whenlbl
isNolabel
andexp0
isNone
,fun ~l:P -> CE
whenlbl
isLabelled l
andexp0
isNone
,fun ?l:P -> CE
whenlbl
isOptional l
andexp0
isNone
,fun ?l:(P = E0) -> CE
whenlbl
isOptional l
andexp0
isSome E0
.
val pcl_structure :
Astlib.Ast_500.Parsetree.class_structure ->
Astlib.Ast_500.Parsetree.class_expr
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_expr
pcl_constr
constructs an Ast.Pcl_constr
Example OCaml
c
and ['a1, ..., 'an] c
Case
val case :
lhs:Astlib.Ast_500.Parsetree.pattern ->
guard:Astlib.Ast_500.Parsetree.expression option ->
rhs:Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.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_op
binding_op
constructs an Ast.binding_op
Attribute
val attribute :
name:string Astlib.Location.loc ->
payload:Astlib.Ast_500.Parsetree.payload ->
Astlib.Ast_500.Parsetree.attribute
attribute
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_infos
open_infos
constructs an Ast.'aopen_infos
Example OCaml
Values of type 'a open_infos
represents:
open! X
whenpopen_override
isOverride
(silences the "used identifier shadowing" warning)open X
whenpopen_override
isFresh
'a include infos
val include_infos : 'a -> 'a Astlib.Ast_500.Parsetree.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_infos
class_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.
val eint : int -> Astlib.Ast_500.Parsetree.expression
val echar : char -> Astlib.Ast_500.Parsetree.expression
val estring : string -> Astlib.Ast_500.Parsetree.expression
val efloat : string -> Astlib.Ast_500.Parsetree.expression
val eint32 : int32 -> Astlib.Ast_500.Parsetree.expression
val eint64 : int64 -> Astlib.Ast_500.Parsetree.expression
val enativeint : nativeint -> Astlib.Ast_500.Parsetree.expression
val ebool : bool -> Astlib.Ast_500.Parsetree.expression
val pint : int -> Astlib.Ast_500.Parsetree.pattern
val pchar : char -> Astlib.Ast_500.Parsetree.pattern
val pstring : string -> Astlib.Ast_500.Parsetree.pattern
val pfloat : string -> Astlib.Ast_500.Parsetree.pattern
val pint32 : int32 -> Astlib.Ast_500.Parsetree.pattern
val pint64 : int64 -> Astlib.Ast_500.Parsetree.pattern
val pnativeint : nativeint -> Astlib.Ast_500.Parsetree.pattern
val pbool : bool -> Astlib.Ast_500.Parsetree.pattern
val eunit : Astlib.Ast_500.Parsetree.expression
val punit : Astlib.Ast_500.Parsetree.pattern
val evar : string -> Astlib.Ast_500.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 -> Astlib.Ast_500.Parsetree.pattern
val eapply :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
Same as pexp_apply but without labels
val eabstract :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
val esequence :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
val ppat_tuple_opt :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.pattern option
val pexp_tuple_opt :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression option
val pconstruct :
Astlib.Ast_500.Parsetree.constructor_declaration ->
Astlib.Ast_500.Parsetree.pattern option ->
Astlib.Ast_500.Parsetree.pattern
val econstruct :
Astlib.Ast_500.Parsetree.constructor_declaration ->
Astlib.Ast_500.Parsetree.expression option ->
Astlib.Ast_500.Parsetree.expression
val elist_tail :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
elist_tail ~loc [expr1; expr2; expr3] expr_tail
produces the expression expr1::expr2::expr3::expr_tail
.
val elist :
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
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.pattern
plist_tail ~loc [pat1; pat2; pat3] pat_tail
produces the pattern pat1::pat2::pat3::pat_tail
.
val plist :
Astlib.Ast_500.Parsetree.pattern list ->
Astlib.Ast_500.Parsetree.pattern
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 list
pstr_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_declaration
val unapplied_type_constr_conv :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Astlib.Ast_500.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:
- 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_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 :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Astlib.Ast_500.Parsetree.expression list ->
Astlib.Ast_500.Parsetree.expression
val eta_reduce :
Astlib.Ast_500.Parsetree.expression ->
Astlib.Ast_500.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:
- if
f
has optional arguments, eta-expandingf
can 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
f
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_500.Parsetree.expression ->
Astlib.Ast_500.Parsetree.expression
val eta_reduce_if_possible_and_nonrec :
Astlib.Ast_500.Parsetree.expression ->
rec_flag:Astlib.Ast_500.Asttypes.rec_flag ->
Astlib.Ast_500.Parsetree.expression
module Latest : sig ... end
This 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 :
Astlib.Longident.t Astlib.Location.loc ->
Astlib.Ast_500.Parsetree.pattern option ->
Astlib.Ast_500.Parsetree.pattern
val constructor_declaration :
name:string Astlib.Location.loc ->
args:Astlib.Ast_500.Parsetree.constructor_arguments ->
res:Astlib.Ast_500.Parsetree.core_type option ->
Astlib.Ast_500.Parsetree.constructor_declaration
- 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