Ast_helper.Cty(3)

πŸ’… Ast_helper.Cty(3) β€” like, the class type expressions module bestie

okay so real talk, this is Ast_helper.Cty straight out of the OCaml library manual, and it's the little helper module you reach for when you're building up class type expressions in the parsetree. it's giving "small but mighty" energy and honestly? iconic. ✨


🌸 NAME 🌸

Ast_helper.Cty β€” Class type expressions. that's it, that's the whole vibe. πŸ’–


πŸ¦‹ Module πŸ¦‹

the module is literally Ast_helper.Cty. yes, the module is named after itself, no cap, that's just how the Ast_helper family rolls 🫢


⭐ Documentation ⭐

okay so here's the whole deal β€” this module is declared as

Module Cty
 : sig end

and it's all about Class type expressions πŸ’… no extra surprises hiding in there, it's just the values listed below, slaying one by one. let's go through the whole roster because every single one of them matters:

  • val mk β€” this is the main character constructor πŸ’– it takes an optional ?loc:Ast_helper.loc, an optional ?attrs:Ast_helper.attrs, and a Parsetree.class_type_desc, and hands you back a Parsetree.class_type. the whole signature, verbatim, because i refuse to butcher it:
val mk : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.class_type_desc -> Parsetree.class_type
  • val attr β€” slap an attribute on a class type πŸŽ€ give it a Parsetree.class_type and a Parsetree.attribute, get a Parsetree.class_type back. no optional args here bestie, it's just those two:
val attr : Parsetree.class_type -> Parsetree.attribute ->
Parsetree.class_type
  • val constr β€” constructor time!! 🧚 optional ?loc:Ast_helper.loc, optional ?attrs:Ast_helper.attrs, then an Ast_helper.lid and a Parsetree.core_type list, and boom you get a Parsetree.class_type. note the list β€” it's plural, it takes many core types, not one:
val constr : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Ast_helper.lid -> Parsetree.core_type list -> Parsetree.class_type
  • val signature β€” wraps a signature into a class type πŸ¦‹ optional ?loc:Ast_helper.loc, optional ?attrs:Ast_helper.attrs, a Parsetree.class_signature, and out comes a Parsetree.class_type:
val signature : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.class_signature -> Parsetree.class_type
  • val arrow β€” the arrow one, very type-theory girlboss of it πŸ”₯ optional ?loc:Ast_helper.loc, optional ?attrs:Ast_helper.attrs, then an Asttypes.arg_label, a Parsetree.core_type, and a Parsetree.class_type β€” which gives you back another Parsetree.class_type. look at all those arrows, it's arrows on arrows:
val arrow : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Asttypes.arg_label -> Parsetree.core_type -> Parsetree.class_type ->
Parsetree.class_type
  • val extension β€” extension node energy ⭐ optional ?loc:Ast_helper.loc, optional ?attrs:Ast_helper.attrs, a Parsetree.extension, and you get a Parsetree.class_type:
val extension : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.extension -> Parsetree.class_type
  • val open_ β€” yes it has the trailing underscore, that's not a typo, that's just OCaml being OCaml πŸ™ˆ optional ?loc:Ast_helper.loc, optional ?attrs:Ast_helper.attrs, a Parsetree.open_description, and a Parsetree.class_type which becomes a Parsetree.class_type:
val open_ : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs ->
Parsetree.open_description -> Parsetree.class_type ->
Parsetree.class_type
heads up bestie: those ?loc:Ast_helper.loc and ?attrs:Ast_helper.attrs args are optional in mk, constr, signature, arrow, extension and open_ β€” but attr has no optional args at all, it's just the two positional ones. don't come for me, that's literally what the page says πŸ’€

and that's the whole page, fr fr β€” every single value accounted for, nothing skipped, nothing invented 🌈

cute little sign-off time: this page is brought to you by OCamldoc, version dated 2026-06-22, and the page itself is Ast_helper.Cty(3) 🫢 go forth and construct your class types, you're gonna eat πŸ’…βœ¨

πŸ“¦ where this page comes from