An endomorphic stage that folds its own inputs into a running accumulator across pipeline runs, via the binary operation stage op — the running-total counterpart of h8io.stages.cycles.Reduce and h8io.stages.cycles.Fold.
Unlike the h8io.stages.cycles family, Scan has no inner stage and no cycle: it consumes one external input per outer run and threads its own accumulator from one run to the next. The first input becomes the accumulator unchanged, without invoking op (the classic seedless reduce, seeded from the pipeline's own input stream instead of a single seed value); each subsequent input is folded via op((accumulator, input)) and the result — the new running total — is emitted immediately, ready for the next run.
When op is applied but itself yields no output — e.g. it filters some inputs out — the accumulator is left unchanged rather than discarded, exactly as in Reduce/Fold, and Scan itself yields nothing for that run.
Since Scan has no separate alterand, the status of a run is simply the status op produced (or Success, for the seeding run in which op is skipped) — there is nothing else to combine it with. Whenever that status is h8io.stages.Status.Complete, the next generation resets to a fresh, unseeded Scan instead of continuing to accumulate — mirroring how h8io.stages.std.Countdown resets on any non-Success status: Complete marks one logical unit of work as finished, and the next external input starts a new one, seeding from scratch.
Type parameters
- E
-
the error type (covariant)
- T
-
the accumulator and input type (invariant: threaded through as both input and output of
op)
Value parameters
- op
-
the binary operation stage folding the accumulator and a new input into the next accumulator
Attributes
- Companion
- object
- Graph
-
- Supertypes