Skip to main content

Module transform

Module transform 

Source
Expand description

Transform operators (R5.7) — element-wise mappings and folds.

Mirrors the TS shapes in ~/src/graphrefly-ts/packages/pure-ts/src/extra/operators/transform.ts, but driven by Core dispatch (graphrefly_core::OperatorOp) instead of derived-fn factories. Per Slice C-1 / D009.

Each factory takes &Core, an &Arc<dyn OperatorBinding> (for registering the user closure), the source node id, the user-supplied callback, and any operator-specific arguments (seeds for folders). The factory:

  1. Registers the user closure on the binding (returns a FnId).
  2. Calls Core::register_operator with the appropriate OperatorOp variant.
  3. Returns an OperatorRegistration carrying the new node id and (for folders) the registered seed handle.

§Refcount discipline

For scan and reduce, the seed handle ownership transfers from the caller’s binding-side intern into Core’s ScanState / ReduceState (post-Slice C-3 / D026 — generic op_scratch slot replaces the typed operator_state field). Core takes one retain via [BindingBoundary::retain_handle] inside register_operator; the caller is expected to retain a share for themselves if they want to reference the seed elsewhere.

Structs§

OperatorRegistration
Output of an operator factory call. Carries the new operator node id plus operator-specific context (e.g., the registered closure’s FnId for traceability / debugging).

Functions§

distinct_until_changed
distinctUntilChanged(source, equals) — suppresses adjacent duplicates.
distinct_until_changed_with
distinct_until_changed with explicit OperatorOpts.
filter
filter(source, predicate) — silent-drop selection (D012/D018).
filter_with
filter with explicit OperatorOpts.
map
map(source, project) — element-wise transform.
map_with
map with explicit OperatorOpts.
pairwise
pairwise(source) — emits (prev, current) pairs starting after the second value. First value is swallowed (used as prev).
pairwise_with
pairwise with explicit OperatorOpts.
reduce
reduce(source, fold, seed) — left-fold emitting once on upstream COMPLETE.
reduce_with
reduce with explicit OperatorOpts.
scan
scan(source, fold, seed) — left-fold emitting each new accumulator.
scan_with
scan with explicit OperatorOpts.