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>,
},
}Expand description
The six-variant operator-tree comprehension.
Closure under composition (spec §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 per spec §3.1. Binds name to one value
per dispense, drawn from source.
Cartesian
Cross-product combinator per spec §3.2. Children must have disjoint name sets (V1).
Fields
children: Vec<Comprehension>The factors.
Zip
Lockstep combinator per spec §3.3. Children must be discrete (V7) and have disjoint name sets (V1).
Union
Concatenation combinator per spec §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 per spec §3.5. Predicate is a GK boolean expression; names must close over the child’s coordinates plus the parent scope (V3).
Fields
child: Box<Comprehension>The stream filtered.
Order
Permutation modifier per spec §3.6. strategy must
accept the child’s IndexFn (V4); truncation limits the
dispensed count.
Implementations§
Source§impl Comprehension
impl Comprehension
Sourcepub fn clause<S>(name: S, source: Source) -> Comprehension
pub fn clause<S>(name: S, source: Source) -> Comprehension
Construct a leaf clause.
Sourcepub fn cartesian(children: Vec<Comprehension>) -> Comprehension
pub fn cartesian(children: Vec<Comprehension>) -> Comprehension
Construct a cartesian over the supplied children.
Sourcepub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Comprehension
pub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Comprehension
Construct a zip over the supplied children with the given mode.
Sourcepub fn union(children: Vec<Comprehension>) -> Comprehension
pub fn union(children: Vec<Comprehension>) -> Comprehension
Construct a union over the supplied children.
Sourcepub fn filter<S>(child: Comprehension, predicate: S) -> Comprehension
pub fn filter<S>(child: Comprehension, predicate: S) -> Comprehension
Construct a filter wrapping child with predicate.
Sourcepub fn order(
child: Comprehension,
strategy: StrategyName,
truncation: Option<u64>,
) -> Comprehension
pub fn order( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, ) -> Comprehension
Construct an order node wrapping child.
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 (per spec §3.2 + §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 round-trip-to-
legacy form — IntRange { 1, 10, 1 } → "1..10",
Literal { [10, 100] } → "10, 100", etc.
Used by the runtime’s per-iter scope-kernel synthesis
to construct a [(var, spec_expr)] list for type
detection (per build_for_each_scope_kernel’s probe
pre-evaluation).
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 (spec §10.6.3).
Source§impl Comprehension
impl Comprehension
Sourcepub fn metadata(&self) -> Metadata
pub fn metadata(&self) -> Metadata
Compute this node’s metadata bundle per spec §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 should wrap externally. This is fine because the propagation cost is O(N) total nodes and the optimizer (Phase 6) re-propagates after each rewrite anyway.
Trait Implementations§
Source§impl Clone for Comprehension
impl Clone for Comprehension
Source§fn clone(&self) -> Comprehension
fn clone(&self) -> Comprehension
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Comprehension
impl Debug for Comprehension
Source§impl<'de> Deserialize<'de> for Comprehension
impl<'de> Deserialize<'de> for Comprehension
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Comprehension, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Comprehension, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Comprehension
impl PartialEq for Comprehension
Source§impl Serialize for Comprehension
impl Serialize for Comprehension
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Comprehension
Auto Trait Implementations§
impl Freeze for Comprehension
impl RefUnwindSafe for Comprehension
impl Send for Comprehension
impl Sync for Comprehension
impl Unpin for Comprehension
impl UnsafeUnpin for Comprehension
impl UnwindSafe for Comprehension
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more