lang::typecheck::traverse
lang/src/typecheck/traverse.mo
Generic one-level structural recursion over the canonical Term tree.
term_map_children f t applies f to every immediate child Term of
t and rebuilds it; f itself decides whether and how to recurse
further, so this file only ever looks one level down. Each sibling
helper does the same for a node kind that carries Terms but isn't
one (Literal, MatchCase, StructLitField, Con, Native, and
the Option/List shapes those use).
Extracted from [[lang/typecheck/macro_expand.mo]], which originally
defined this family for expand_term/resolve_quote's own fallback
cases. It was already being imported across module boundaries by
lang/scope.mo's resolve_infix_term, so it was shared
infrastructure in practice before it was one by name -- this module
makes that explicit and gives the substitution walkers
([[lang/typecheck/name_subst.mo]], [[lang/typecheck/subst.mo]]) a
home to build on rather than re-deriving the same ~10 helpers each.
pub def term_map_children (f : Term -> Term) (t : Term) : Termpub def result_bind {A B : Type} (r : Result String A) (k : A -> Result String B) : Result String BShort-circuiting bind for Result String (there is no Monad (Result E) instance in the prelude, and this walk should not need
one).
pub def term_map_children_result (f : Term -> Result String Term) (t : Term) : Result String Termpub def term_children (t : Term) : List Termpub def literal_children (l : Literal) : List Term