Skip to main content

Comprehension

Enum Comprehension 

Source
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.

Fields

§name: String

The name bound.

§source: Source

Where the values come from.

§

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).

Fields

§children: Vec<Comprehension>

The streams zipped.

§mode: ZipMode

The length policy.

§

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.

§predicate: String

The predicate, a boolean expression over the tuple and the parent scope.

§

Order

Permutation modifier per spec §3.6. strategy must accept the child’s IndexFn (V4); truncation limits the dispensed count.

Fields

§child: Box<Comprehension>

The stream ordered.

§strategy: StrategyName

The strategy applied.

§truncation: Option<u64>

The dispensed count cap, if any.

Implementations§

Source§

impl Comprehension

Source

pub fn clause<S>(name: S, source: Source) -> Comprehension
where S: Into<String>,

Construct a leaf clause.

Source

pub fn cartesian(children: Vec<Comprehension>) -> Comprehension

Construct a cartesian over the supplied children.

Source

pub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Comprehension

Construct a zip over the supplied children with the given mode.

Source

pub fn union(children: Vec<Comprehension>) -> Comprehension

Construct a union over the supplied children.

Source

pub fn filter<S>(child: Comprehension, predicate: S) -> Comprehension
where S: Into<String>,

Construct a filter wrapping child with predicate.

Source

pub fn order( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, ) -> Comprehension

Construct an order node wrapping child.

Source

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.

Source

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).

Source

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.

Source

pub fn is_clause(&self) -> bool

true if this node is a leaf clause.

Source

pub fn is_combinator(&self) -> bool

true if this node is one of the three combinators.

Source

pub fn is_modifier(&self) -> bool

true if this node is a modifier (filter or order).

Source

pub fn children(&self) -> Box<dyn Iterator<Item = &Comprehension> + '_>

Iterate this node’s direct operand children. Returns an empty iterator for leaf clauses.

Source

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

pub fn depth(&self) -> usize

Maximum depth of the AST. Constant for flat composition, O(log N) for balanced trees. Bounds the operator stack per spec §9.3.

Source§

impl Comprehension

Source

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

Source§

fn clone(&self) -> Comprehension

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Comprehension

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Comprehension

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Comprehension, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Comprehension

Source§

fn eq(&self, other: &Comprehension) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Comprehension

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Comprehension

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more