Ast_helper.Exp(3)
π Ast_helper.Exp β the manual, but make it cute π
Hiii bestie π
so this page lives in the OCaml library manual and it's called Ast_helper.Exp(3). It's all about Expressions β like, the whole thing. Every function here is a little helper that builds you a Parsetree expression-shaped thing out of its ingredients. It's giving "AST construction, but make it ergonomic." π¦
β¨ NAME β¨
Ast_helper.Exp β Expressions β¨
No cap, that's the whole name section. Short king. π
π MODULE π
The module is literally:
Module Ast_helper.Exp
Yeah. That's it. It is itself. Main character energy. π
π DOCUMENTATION π
πΈ Module Exp πΈ
Module Exp
: sig end
So it's a module named Exp whose signature is sig end β the docs are just showing you the module shape and then moving on, because the good stuff is inside. Keep scrolling, bestie π
π«Ά Expressions π«Ά
Okay so here's the tea β β every single one of these bad boys takes these two optional lil cuties first:
?loc:Ast_helper.loc?attrs:Ast_helper.attrs
That's the shared uniform, iykyk. Then the actual arguments come after, and you get a Parsetree.expression back at the end. Let's go through them one by one, no skipping, I promise π―
mkβ takes aParsetree.expression_desc, hands you back aParsetree.expression. The blueprint-to-building pipeline. ποΈ
val mk : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression_desc -> Parsetree.expression
attrβ this one's different, bestie! It takes the expression first and there are no?loc/?attrshere β it'sParsetree.expression -> Parsetree.attribute -> Parsetree.expression. Two positional args, no optional drama. π
val attr : Parsetree.expression -> Parsetree.attribute ->
Parsetree.expression
identβ give it anAst_helper.lidand you get an expression. Ident-ity crisis? Never heard of her. πͺ
val ident : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.lid -> Parsetree.expression
constantβ anAst_helper.lid's calm cousin. You feed it aParsetree.constant, it gives you an expression. Consistent. Reliable. Slay. π
val constant : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.constant -> Parsetree.expression
let_β yes with the underscore, that's not a typo π. AnAsttypes.rec_flag, aParsetree.value_binding list, and an expression walk in; an expression walks out.
val let_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Asttypes.rec_flag -> Parsetree.value_binding list ->
Parsetree.expression -> Parsetree.expression
function_β underscore again, we love a keyword-dodging queen π. Takes aParsetree.function_param list, aParsetree.type_constraint option, and aParsetree.function_body.
val function_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.function_param list -> Parsetree.type_constraint option ->
Parsetree.function_body -> Parsetree.expression
applyβ the application one. An expression plus a(Asttypes.arg_label * Parsetree.expression) listand boom, expression. It's giving "you had one job and you applied yourself." π
val apply : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> (Asttypes.arg_label * Parsetree.expression) list
-> Parsetree.expression
match_β trailing underscore, she's shy π«£. An expression and aParsetree.case listgo in, an expression comes out.
val match_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.case list -> Parsetree.expression
try_β same shape as her sistermatch_, also rocking the underscore. Expression +Parsetree.case listβ expression. Try her, she's flawless β¨
val try_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.case list -> Parsetree.expression
tupleβ a(string option * Parsetree.expression) listin, an expression out. Note thestring optionin there, that's real and I'm not making it up π₯
val tuple : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> (string
option * Parsetree.expression) list -> Parsetree.expression
constructβ anAst_helper.lidplus aParsetree.expression option, and you get an expression. Construction project: complete β
val construct : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.lid -> Parsetree.expression option -> Parsetree.expression
variantβ anAsttypes.labeland aParsetree.expression optionwalk in. Variant hours, who's she π¦
val variant : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Asttypes.label -> Parsetree.expression option -> Parsetree.expression
recordβ a(Ast_helper.lid * Parsetree.expression) listand aParsetree.expression optionat the end, then out pops an expression. Two-part situation, stay with me π
val record : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
(Ast_helper.lid * Parsetree.expression) list -> Parsetree.expression
option -> Parsetree.expression
fieldβ expression, thenAst_helper.lid, then expression. Order matters, don't @ me π
val field : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Ast_helper.lid -> Parsetree.expression
setfieldβ three positional besties: expression,Ast_helper.lid, expression. (Yes, that's what's written. Yes, it's a lot. Yes, it's iconic.) π₯
val setfield : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Ast_helper.lid -> Parsetree.expression ->
Parsetree.expression
arrayβ aParsetree.expression listgoes in, one expression comes out. Many become one. Girl group energy. π€
val array : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression list -> Parsetree.expression
ifthenelseβ expression, expression, then aParsetree.expression option(that's your else branch being optional, nudge nudge), then expression. π
val ifthenelse : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.expression -> Parsetree.expression
option -> Parsetree.expression
sequenceβ expression, expression, expression. Two in, one out. Do them in order, bestie β‘οΈ
val sequence : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.expression -> Parsetree.expression
while_β underscore, obviously π . Two expressions in, one expression out.
val while_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.expression -> Parsetree.expression
for_β the long one, buckle up π’.Parsetree.pattern, then two expressions, then anAsttypes.direction_flag, then another expression. Five positional arguments, all accounted for, none of them optional.
val for_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.pattern -> Parsetree.expression -> Parsetree.expression ->
Asttypes.direction_flag -> Parsetree.expression -> Parsetree.expression
coerceβ an expression, aParsetree.core_type option, and aParsetree.core_type. Glow-up transformation arc β¨
val coerce : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.core_type option ->
Parsetree.core_type -> Parsetree.expression
constraint_β underscore gang πͺ. An expression and aParsetree.core_type.
val constraint_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.core_type -> Parsetree.expression
sendβ an expression and anAst_helper.str. Sending it, fr fr π¨
val send : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Ast_helper.str -> Parsetree.expression
new_β underscore becausenewwas taken π. Just anAst_helper.lid, that's the whole meal.
val new_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.lid -> Parsetree.expression
setinstvarβAst_helper.strfirst, then an expression. Note the order, it's not the same asfieldup there π
val setinstvar : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.str -> Parsetree.expression -> Parsetree.expression
overrideβ a(Ast_helper.str * Parsetree.expression) list. Just the one listy arg. Simple, clean, ate π
val override : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
(Ast_helper.str * Parsetree.expression) list -> Parsetree.expression
assert_β underscore, she's asserting herself πββοΈ. One expression in, one out.
val assert_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.expression
lazy_β underscore AND lazy. Truly the mood. One expression in, one out. π΄
val lazy_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.expression
polyβ an expression plus aParsetree.core_type option, out comes an expression. Polymorphic and proud π
val poly : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.core_type option ->
Parsetree.expression
object_β underscore, and it takes aParsetree.class_structure. Object-oriented moment, we stan π
val object_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.class_structure -> Parsetree.expression
newtypeβ anAst_helper.strand an expression, then expression. Fresh type, fresh me π«
val newtype : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.str -> Parsetree.expression -> Parsetree.expression
packβ aParsetree.module_exprplus aParsetree.package_type option. Pack it up, pack it in π§³
val pack : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.module_expr -> Parsetree.package_type option ->
Parsetree.expression
letopβ aParsetree.binding_op, then aParsetree.binding_op list, then an expression. Let-operators said "we're here too" π₯
val letop : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.binding_op -> Parsetree.binding_op list ->
Parsetree.expression -> Parsetree.expression
extensionβ takes aParsetree.extension. Extension representation, periodt. β
val extension : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.extension -> Parsetree.expression
unreachableβ takes literallyunit(so(), the emptiest queen alive) and gives you an expression. Haunting. π
val unreachable : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> unit
-> Parsetree.expression
struct_itemβ aParsetree.structure_itemand aParsetree.expressiongo in, one expression comes out. Structure, but make it an expression ποΈ
val struct_item : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.structure_item -> Parsetree.expression -> Parsetree.expression
caseβ β οΈ heads up bestie, this one plays by its own rules: no?loc, no?attrs, and it returns aParsetree.case, not an expression. It'sParsetree.pattern, then?guard:Parsetree.expression(a named optional β note the label!), thenParsetree.expression.
val case : Parsetree.pattern -> ?guard:Parsetree.expression ->
Parsetree.expression -> Parsetree.case
binding_opβ also a rebel π«£. No?loc/?attrs, and the return type isParsetree.binding_op. Order is:Ast_helper.str,Parsetree.pattern,Parsetree.expression, thenAst_helper.loclast, not optional, no question mark.
val binding_op : Ast_helper.str -> Parsetree.pattern ->
Parsetree.expression -> Ast_helper.loc -> Parsetree.binding_op
π‘ Friendly reminder from your girl:attr,case, andbinding_opare the three that don't do the?loc/?attrsthing, andcase+binding_opgive you backParsetree.case/Parsetree.binding_opinstead of an expression. Don't get caught out, iykyk π«Ά
π Sign-off π
That's the whole page, bestie β no crumbs left, no options skipped, every signature exactly where it belongs πβ¨π
This little masterpiece was brought to you by OCamldoc, dated 2026-06-22, living at Ast_helper.Exp(3). Like, she's documented, she's dated, she's iconic. Periodt. ππ
π¦
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms