pub enum Comprehension {
Clause {
name: String,
source: Source,
},
Cartesian {
children: Vec<Comprehension>,
},
Zip {
children: Vec<Comprehension>,
mode: ZipMode,
},
Union {
children: Vec<Comprehension>,
},
Filter {
child: Box<Comprehension>,
predicate: String,
},
Order {
child: Box<Comprehension>,
strategy: StrategyName,
truncation: Option<u64>,
seed: Option<u64>,
},
}Expand description
The six-variant operator-tree comprehension.
Closure under composition (comprehension_forms.md §4.1 C1): every variant
holds one or more Comprehension operands plus
constructor-specific scalar parameters (predicate, strategy,
truncation, zip mode, source).
Box<Comprehension> appears wherever a variant needs a
single child operand; Vec<Comprehension> wherever a
constructor takes N children (cartesian, zip, union).
Variants§
Clause
Leaf source (comprehension_forms.md §3.1). Binds name to one value
per dispense, drawn from source.
Cartesian
Cross-product combinator (comprehension_forms.md §3.2). Children must have disjoint name sets (V1).
Fields
children: Vec<Comprehension>The factors.
Zip
Lockstep combinator (comprehension_forms.md §3.3). Children must be discrete (V7) and have disjoint name sets (V1).
Union
Concatenation combinator (comprehension_forms.md §3.4). Children must share an identical tuple shape (V2) and all be discrete (V9).
Fields
children: Vec<Comprehension>The streams concatenated, in order.
Filter
Selection modifier (comprehension_forms.md §3.5). The predicate is a Polydat boolean expression (§10.9.1); names must close over the child’s coordinates plus the parent scope (V3).
Fields
child: Box<Comprehension>The stream filtered.
Order
Permutation modifier (comprehension_forms.md §3.6). strategy must
accept the child’s IndexFn (V4); truncation limits the
dispensed count; seed is the authored seed a seeded
strategy (Shuffle, Lhs) derives its state from, with a
fixed default when absent.
Implementations§
Source§impl Comprehension
impl Comprehension
Sourcepub fn cartesian(children: Vec<Comprehension>) -> Self
pub fn cartesian(children: Vec<Comprehension>) -> Self
Construct a cartesian over the supplied children.
Sourcepub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Self
pub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Self
Construct a zip over the supplied children with the given mode.
Sourcepub fn union(children: Vec<Comprehension>) -> Self
pub fn union(children: Vec<Comprehension>) -> Self
Construct a union over the supplied children.
Sourcepub fn filter<S: Into<String>>(child: Comprehension, predicate: S) -> Self
pub fn filter<S: Into<String>>(child: Comprehension, predicate: S) -> Self
Construct a filter wrapping child with predicate.
Sourcepub fn order(
child: Comprehension,
strategy: StrategyName,
truncation: Option<u64>,
) -> Self
pub fn order( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, ) -> Self
Construct an order node wrapping child, with no authored
seed.
Sourcepub fn order_seeded(
child: Comprehension,
strategy: StrategyName,
truncation: Option<u64>,
seed: Option<u64>,
) -> Self
pub fn order_seeded( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, seed: Option<u64>, ) -> Self
Construct an order node wrapping child with an authored
seed, which Shuffle and Lhs derive their state from.
Sourcepub fn coordinate_names(&self) -> Vec<String>
pub fn coordinate_names(&self) -> Vec<String>
Compute the comprehension’s coordinate name set, recursively. The result preserves declaration order (comprehension_forms.md §3.2 and §3.4’s “in declaration order” tuple shape rules). Used by V1, V2, V3, and the predicate analyzer’s coord-set input.
Sourcepub fn coordinate_specs(&self) -> Vec<(String, String)>
pub fn coordinate_specs(&self) -> Vec<(String, String)>
Compute (coordinate_name, source_text) pairs in
declaration order, deduplicated by name (first
occurrence wins). Source text is the clause text form —
IntRange { 1, 10, 1 } → "1..10",
Literal { [10, 100] } → "10, 100", etc.
Gives a consumer a [(var, spec_expr)] list for type
detection, the spec-text shape the runtime’s probe
pre-evaluation (pre_evaluate_clause) takes.
Sourcepub fn referenced_source_names(&self) -> BTreeSet<String>
pub fn referenced_source_names(&self) -> BTreeSet<String>
Grammar-based extraction of the free names referenced by
every source spec in this comprehension subtree —
workload params, outer iter-vars, and wires that a
Generator spec (concat(foo), bare eh_values)
consumes. Each spec is parsed with the canonical Polydat
expression grammar (crate::refs::referenced_names)
rather than byte-scanned, so a bare source reference is
recognised exactly as the kernel compiler would resolve
it. WorkloadParamList { name } contributes name
directly; literals / ranges / intervals contribute
nothing. Used by the workload validator’s
declared-but-unreferenced check.
Sourcepub fn is_combinator(&self) -> bool
pub fn is_combinator(&self) -> bool
true if this node is one of the three combinators.
Sourcepub fn is_modifier(&self) -> bool
pub fn is_modifier(&self) -> bool
true if this node is a modifier (filter or order).
Sourcepub fn children(&self) -> Box<dyn Iterator<Item = &Comprehension> + '_>
pub fn children(&self) -> Box<dyn Iterator<Item = &Comprehension> + '_>
Iterate this node’s direct operand children. Returns an empty iterator for leaf clauses.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count of nodes in the AST (this node + all descendants). Used by the optimizer’s well-founded measure for termination (comprehension_forms.md §10.6, property 3).
Source§impl Comprehension
impl Comprehension
Sourcepub fn metadata(&self) -> Metadata
pub fn metadata(&self) -> Metadata
Compute this node’s metadata bundle (comprehension_forms.md §10.7.2).
Bottom-up: every child’s metadata is computed first, then this node’s. Constant-time per node above the child cost. Total — never fails, never partial.
For non-leaf nodes the metadata is recomputed on every call (no caching at this layer); consumers that need memoization wrap it externally. The propagation cost is O(N) in the nodes, and the optimizer re-propagates after each rewrite.