---
name: "Ast_iterator"
section: "3o"
platform: "linux"
package: "ocaml"
version: "5.5.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Ast_iterator"
---

# Ast\_iterator(3o)

Ast\_iterator.iterator enables AST inspection using open recursion.

## NAME

Ast\_iterator - Ast\_iterator.iterator enables AST inspection using open recursion.

## Module

Module   Ast\_iterator

## Documentation

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.

Warning: this module is unstable and part of **Compiler\_libs** .

### A generic Parsetree iterator

*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** ;\
  }

A  **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.

*val default\_iterator* :  **iterator**

A default iterator, which implements a "do not do anything" mapping.
