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:
- Registers the user closure on the binding (returns a
FnId). - Calls
Core::register_operatorwith the appropriateOperatorOpvariant. - Returns an
OperatorRegistrationcarrying 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§
- Operator
Registration - Output of an operator factory call. Carries the new operator node id
plus operator-specific context (e.g., the registered closure’s
FnIdfor traceability / debugging).
Functions§
- distinct_
until_ changed distinctUntilChanged(source, equals)— suppresses adjacent duplicates.- distinct_
until_ changed_ with distinct_until_changedwith explicitOperatorOpts.- filter
filter(source, predicate)— silent-drop selection (D012/D018).- filter_
with filterwith explicitOperatorOpts.- map
map(source, project)— element-wise transform.- map_
with mapwith explicitOperatorOpts.- pairwise
pairwise(source)— emits(prev, current)pairs starting after the second value. First value is swallowed (used asprev).- pairwise_
with pairwisewith explicitOperatorOpts.- reduce
reduce(source, fold, seed)— left-fold emitting once on upstream COMPLETE.- reduce_
with reducewith explicitOperatorOpts.- scan
scan(source, fold, seed)— left-fold emitting each new accumulator.- scan_
with scanwith explicitOperatorOpts.