Ast_iterator(3)
💖 Ast_iterator(3) 💖
okay bestie, welcome to the Ast_iterator(3) page from the OCaml library manual — this one is all about AST inspection energy ✨
🌸 NAME 🌸
Ast_iterator — Ast_iterator.iterator enables AST inspection using open recursion. 🫶
🧚 MODULE 🧚
Module: Ast_iterator
✨ DOCUMENTATION ✨
Here’s the module signature line, untouched and iconic:
Module Ast_iterator : sig end
Ast_iterator.iterator enables AST inspection using open recursion. A typical mapper would be based on Ast_iterator.default_iterator — a trivial iterator — and will fall back on it for handling the syntax it does not modify. No cap, that’s the whole vibe. 💅
🚨 Warning: this module is unstable and part of Compiler_libs.
🦋 A generic Parsetree iterator 🦋
Type time, bestie — here’s the full iterator record, every field in its rightful place:
type iterator = {
attribute : iterator -> Parsetree.attribute -> unit ;
attributes : iterator -> Parsetree.attribute list -> unit ;
binding_op : iterator -> Parsetree.binding_op -> unit ;
case : iterator -> Parsetree.case -> unit ;
cases : iterator -> Parsetree.case list -> unit ;
class_declaration : iterator -> Parsetree.class_declaration -> unit ;
class_description : iterator -> Parsetree.class_description -> unit ;
class_expr : iterator -> Parsetree.class_expr -> unit ;
class_field : iterator -> Parsetree.class_field -> unit ;
class_signature : iterator -> Parsetree.class_signature -> unit ;
class_structure : iterator -> Parsetree.class_structure -> unit ;
class_type : iterator -> Parsetree.class_type -> unit ;
class_type_declaration : iterator -> Parsetree.class_type_declaration -> unit ;
class_type_field : iterator -> Parsetree.class_type_field -> unit ;
constructor_declaration : iterator -> Parsetree.constructor_declaration -> unit ;
directive_argument : iterator -> Parsetree.directive_argument -> unit ;
expr : iterator -> Parsetree.expression -> unit ;
extension : iterator -> Parsetree.extension -> unit ;
extension_constructor : iterator -> Parsetree.extension_constructor -> unit ;
include_declaration : iterator -> Parsetree.include_declaration -> unit ;
include_description : iterator -> Parsetree.include_description -> unit ;
label_declaration : iterator -> Parsetree.label_declaration -> unit ;
location : iterator -> Location.t -> unit ;
module_binding : iterator -> Parsetree.module_binding -> unit ;
module_declaration : iterator -> Parsetree.module_declaration -> unit ;
module_substitution : iterator -> Parsetree.module_substitution -> unit ;
module_expr : iterator -> Parsetree.module_expr -> unit ;
module_type : iterator -> Parsetree.module_type -> unit ;
module_type_declaration : iterator -> Parsetree.module_type_declaration -> unit ;
open_declaration : iterator -> Parsetree.open_declaration -> unit ;
open_description : iterator -> Parsetree.open_description -> unit ;
package_type : iterator -> Parsetree.package_type -> unit ;
pat : iterator -> Parsetree.pattern -> unit ;
payload : iterator -> Parsetree.payload -> unit ;
signature : iterator -> Parsetree.signature -> unit ;
signature_item : iterator -> Parsetree.signature_item -> unit ;
structure : iterator -> Parsetree.structure -> unit ;
structure_item : iterator -> Parsetree.structure_item -> unit ;
toplevel_directive : iterator -> Parsetree.toplevel_directive -> unit ;
toplevel_phrase : iterator -> Parsetree.toplevel_phrase -> unit ;
typ : iterator -> Parsetree.core_type -> unit ;
row_field : iterator -> Parsetree.row_field -> unit ;
object_field : iterator -> Parsetree.object_field -> unit ;
type_declaration : iterator -> Parsetree.type_declaration -> unit ;
type_extension : iterator -> Parsetree.type_extension -> unit ;
type_exception : iterator -> Parsetree.type_exception -> unit ;
type_kind : iterator -> Parsetree.type_kind -> unit ;
value_binding : iterator -> Parsetree.value_binding -> unit ;
value_description : iterator -> Parsetree.value_description -> unit ;
with_constraint : iterator -> Parsetree.with_constraint -> unit ;
}
An iterator record implements one “method” per syntactic category, using an open recursion style: each method takes as its first argument the iterator to be applied to children in the syntax tree. Literally so organized. 🌈
val default_iterator : iterator
A default iterator, which implements a “do not do anything” mapping. It’s the chill default — lowkey iconic. 🫶
Source/version:OCamldoc· date:2026-06-22· page:Ast_iterator(3)— bye bestie, go traverse something cute 💅💖✨
📦 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