Ast_helper.Ctf(3)

πŸ’… NAME

okay so bestie, welcome to Ast_helper.Ctf β€” it's literally Class type fields, and it's the whole entire vibe of this page. no cap. πŸ¦‹


πŸŽ€ Module

the module is Ast_helper.Ctf, full stop, periodt. that's the address, that's the vibe, that's where you're at. πŸ’–


✨ Documentation

so like, here's the tea: this module is a sig, as in:

Module Ctf
 : sig end

and what it does β€” Class type fields β€” is give you little helpers for building class type field nodes in the OCaml AST. it's giving backstage-pass-to-the-parsetree energy, and honestly? iconic. πŸ‘‘

here's every single one of them, in order, no skipping, we don't do that here:

πŸ’œ mk

val mk : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       ?docs:Docstrings.docs -> Parsetree.class_type_field_desc ->
       Parsetree.class_type_field

the main-character constructor fr fr. you hand it a Parsetree.class_type_field_desc and you get a Parsetree.class_type_field back. optionally you can pass ?loc (an Ast_helper.loc), ?attrs (an Ast_helper.attrs), and ?docs (a Docstrings.docs) if you're feeling fancy. πŸŽ€

🌸 attr

val attr : Parsetree.class_type_field -> Parsetree.attribute ->
       Parsetree.class_type_field

slap an attribute onto an existing Parsetree.class_type_field and get the new Parsetree.class_type_field back. it's the little glow-up button. ✨

πŸ¦‹ inherit_

val inherit_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       Parsetree.class_type -> Parsetree.class_type_field

takes a Parsetree.class_type and turns it into a Parsetree.class_type_field β€” the inherit of the class-type world. optional ?loc ( Ast_helper.loc ) and ?attrs ( Ast_helper.attrs ) as always, bestie. note the trailing underscore, she's not plain inherit because OCaml said so. πŸ’…

πŸ”₯ val_

val val_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       Ast_helper.str -> Asttypes.mutable_flag -> Asttypes.virtual_flag ->
       Parsetree.core_type -> Parsetree.class_type_field

okay so this one's stacked: optional ?loc ( Ast_helper.loc ), optional ?attrs ( Ast_helper.attrs ), then an Ast_helper.str, an Asttypes.mutable_flag, an Asttypes.virtual_flag, and a Parsetree.core_type, and out comes a Parsetree.class_type_field. four required args, no skimping. also yes, trailing underscore again. πŸ™ˆ

🌈 method_

val method_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       Ast_helper.str -> Asttypes.private_flag -> Asttypes.virtual_flag ->
       Parsetree.core_type -> Parsetree.class_type_field

same shape as val_ but make it method β€” optional ?loc ( Ast_helper.loc ), optional ?attrs ( Ast_helper.attrs ), an Ast_helper.str, an Asttypes.private_flag (different flag! not mutable, private!), an Asttypes.virtual_flag, and a Parsetree.core_type, producing a Parsetree.class_type_field. reading comprehension check passed, slay. πŸ’–

πŸ’€ constraint_

val constraint_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       Parsetree.core_type -> Parsetree.core_type -> Parsetree.class_type_field

two Parsetree.core_types walk into a bar, plus optional ?loc ( Ast_helper.loc ) and ?attrs ( Ast_helper.attrs ), and out comes a Parsetree.class_type_field. yes it's constraint_ with the underscore, we've been through this. 😭

⭐ extension

val extension : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
       Parsetree.extension -> Parsetree.class_type_field

takes a Parsetree.extension, plus the usual optional ?loc ( Ast_helper.loc ) and ?attrs ( Ast_helper.attrs ), and gives you a Parsetree.class_type_field. extension nodes stay winning. 🧚

πŸ“ attribute

val attribute : ?loc:Ast_helper.loc -> Parsetree.attribute ->
       Parsetree.class_type_field

note the difference from attr above, bestie β€” this one builds a Parsetree.class_type_field out of a Parsetree.attribute, with an optional ?loc ( Ast_helper.loc ). no ?attrs here. don't mix them up or I will cry. πŸŽ€

πŸ‘‘ text

val text : Docstrings.text -> Parsetree.class_type_field list

takes a Docstrings.text and gives you back a list of Parsetree.class_type_field β€” yes a whole list, because one field was never enough for this queen. 🌸

lowkey important reminder: every signature above is copied character for character β€” the ?loc:Ast_helper.loc, the ?attrs:Ast_helper.attrs, the ?docs:Docstrings.docs on mk, all of the Asttypes.mutable_flag / Asttypes.private_flag / Asttypes.virtual_flag business, the Ast_helper.str, the Parsetree.core_type, Parsetree.extension, Parsetree.attribute, Docstrings.text, and Parsetree.class_type_field list. nothing dropped, nothing "cleaned up". 🫢

that's the whole page, bestie β€” no SEE ALSO, no env vars, no exit codes, just pure class-type-field helper energy. this manual page came from OCamldoc, dated 2026-06-22, so go forth and construct your Parsetree.class_type_fields with main character confidence. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from