Ast_helper.Cf(3)
β¨ Ast_helper.Cf β¨
okay bestie so this page is from the OCaml library manual β the <pink>Ast_helper.Cf(3)</pink> one specifically β and it's literally all about class fields. that's it, that's the vibe π
πΈ NAME πΈ
Ast_helper.Cf β class fields, periodt π
π¦ Module π¦
Module Ast_helper.Cf
π Documentation π
so here's the whole module, laid out in its little sig block:
Module Cf
: sig end
and what does it do? class fields, no cap β¨
π§ the constructor β mk
val mk : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
?docs:Docstrings.docs -> Parsetree.class_field_desc ->
Parsetree.class_field
this is the main character constructor fr β you hand it a Parsetree.class_field_desc and it gives you back a Parsetree.class_field. optional bits: ?loc for the location, ?attrs for attributes, ?docs for docstrings. everything else? iconic, default behaviour. π«Ά
π attr
val attr : Parsetree.class_field -> Parsetree.attribute ->
Parsetree.class_field
slap an attribute onto a class field and get the class field back. lowkey simple, highkey useful π
π inherit_
val inherit_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Asttypes.override_flag -> Parsetree.class_expr -> Ast_helper.str option
-> Parsetree.class_field
the inherit one β note the trailing underscore in the name, that's not a typo, bestie, inherit is a keyword π. takes an Asttypes.override_flag, a Parsetree.class_expr, and an Ast_helper.str option, plus the usual ?loc and ?attrs. gives you a Parsetree.class_field. slay.
β val_
val val_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.str -> Asttypes.mutable_flag -> Parsetree.class_field_kind ->
Parsetree.class_field
yes another underscore-ified keyword β val_ π₯². you give it an Ast_helper.str (the name), an Asttypes.mutable_flag (mutable or not, the eternal question), and a Parsetree.class_field_kind. out comes a Parsetree.class_field. ?loc and ?attrs ride along as always.
π method_
val method_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.str -> Asttypes.private_flag -> Parsetree.class_field_kind ->
Parsetree.class_field
same energy as val_ but make it a method π
. Ast_helper.str, an Asttypes.private_flag (private or public, choose your fighter), and a Parsetree.class_field_kind. optional ?loc, optional ?attrs. boom, Parsetree.class_field.
π₯ constraint_
val constraint_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.core_type -> Parsetree.core_type -> Parsetree.class_field
two Parsetree.core_types walk into a bar β one Parsetree.class_field walks out. it's giving type constraint realness β¨ (?loc and ?attrs are there too, obviously).
π§ββοΈ initializer_
val initializer_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.expression -> Parsetree.class_field
wrap up a Parsetree.expression as an initializer class field. ?loc + ?attrs, standard issue π
π extension
val extension : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.extension -> Parsetree.class_field
extension node in, class field out. same optional suspects: ?loc, ?attrs. no notes, ate. π₯
π attribute
val attribute : ?loc:Ast_helper.loc -> Parsetree.attribute ->
Parsetree.class_field
turns a bare Parsetree.attribute into a Parsetree.class_field. this one's only got ?loc β no ?attrs, because the attribute is the content, iykyk π
π text
val text : Docstrings.text -> Parsetree.class_field list
feed it a Docstrings.text and it hands you back a Parsetree.class_field list β a whole list, not one, so she's generous πΈ
π¦ virtual_
val virtual_ : Parsetree.core_type -> Parsetree.class_field_kind
this one spits out a Parsetree.class_field_kind directly (not a field!) and takes a single Parsetree.core_type. virtual era π
β concrete
val concrete : Asttypes.override_flag -> Parsetree.expression ->
Parsetree.class_field_kind
the counterpart to virtual_ β give it an Asttypes.override_flag and a Parsetree.expression, get a Parsetree.class_field_kind. concrete girl summer π
fr fr: every single signature up there is pasted exact β type names,?loc,?attrs,?docs, the flags, the underscores, all of it. don't be out here retyping them from memory π
and that's the whole page bestie π«Ά generated by OCamldoc, dated 2026-06-22, no edits, no notes, just vibes. mwah π
π¦ 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