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