Skip to main content

Module shape

Module shape 

Source
Expand description

Shape<N> — a leaf wrapped in an ordered stack of structural layers (Option, Vec), with a bottom-up fold_shape combinator.

One shared algebra replaces the three former per-module copies of the same “leaf + wrapper layers” idea:

  • jnigen’s FoldStrategy (Direct / Nullable { kind, inner } / Iterable) → Shape<NullableKind> (the Optional layer carries the null-representation choice),
  • expand’s FoldShape (Construct / Optional / Iterable) → Shape (= Shape<()>),
  • unfold’s UnfoldShape (Decompose / Optional / Iterable) → Shape.

N is the per-Optional-layer payload: () for the language-agnostic engines, an adapter type (e.g. jnigen’s NullableKind) where the layer needs to remember how null is represented over the wire.

Enums§

Shape
A base leaf wrapped in zero or more Optional / Iterable layers, from the inside out. N is the payload each Optional layer carries.

Functions§

fold_shape
Bottom-up fold over the layer stack: compute the leaf value with on_base, then apply on_optional / on_iterable for each wrapping layer from the inside out. on_optional also receives the layer’s payload &N and the Shape it wraps, so callers can special-case e.g. a layer sitting directly over the leaf.