Inspect pipelines with explain()
explain() and explainPure() (from @stopcock/fp/fusion/debug) describe
what running a set of steps through pipe does at runtime. Since there’s no
runtime fusion engine any more, the answer is always the same one:
import { explain } from '@stopcock/fp/fusion/debug'import * as A from '@stopcock/fp/array'
explain( A.map((value: number) => value * 2), A.filter((value: number) => value > 10), A.take(3),)// 'sequential'explain() returns the string 'sequential' for any set of steps, always.
pipe runs each one in order, one call at a time — there’s no plan to
report beyond that. The return type also allows 'compiled site', but you
will never observe it: if @stopcock/fp-compiler recognizes and fuses a
call at build time, the fused loop replaces the call outright, and this
function never runs for it. A truly compiled site never calls explain()
at all — there’s nothing left there to ask.
Why this function still exists
Section titled “Why this function still exists”Steps built from @stopcock/fp operators and ordinary opaque functions now
run identically through pipe: in order, one at a time. explain() is a
holdover from the pre-2.0 runtime engine, which used to plan tagged
operators into streaming segments, materialization boundaries, and
specialized executors, and this function described that plan. That plan
doesn’t exist any more, so there’s nothing left to describe beyond the one
constant answer above.
If you want to know whether a specific call site in your own source will actually get fused, that’s a build-time question, not a runtime one — ask the compiler directly:
stopcock check --strict srcThis reports, per call site, whether @stopcock/fp-compiler recognized and
fused it or bailed and left it as an ordinary call, and why. See
@stopcock/fp-compiler for the diagnostics
options and Fusion for what fusing actually changes.
explainPure() is explain() under a different name, kept for source
parity with compilePure’s assumePure option. It also always returns
'sequential'.