| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Agent.Machina.Mark
Contents
Description
Mark-driven halt machinery for STM agents.
This module graduates the first machina probe-station combinator into
circuits-agent. The design principle: the builder posts its silence as a
token, and the runner halts on that read. There is no orElse fallback —
absence is not an opinion here. If the mark never arrives, the runner
blocks; the halt is decided by content, not inferred from quiet.
The 'Loop Either' form pushes the same halt to the surface of a composition:
Left = continue, Right = halt. This makes the mark-halt a trace citizen,
with the continuation folded away by trace.
The rest of the machina probe station (quiet ends, sealed ends, stream ends)
stays in circuits-agent-machina until a consumer appears here.
Mark-driven halt
spinMark :: (a -> Bool) -> (s -> a -> s) -> Poles (K STM) a a -> K STM s s Source #
Spin until the mark is read: the builder posts its silence as a token,
and the runner halts on that read. No orElse — absence is not an opinion
here. If the mark never arrives, this blocks; the halt is decided by
content, not inferred from quiet.
Contrast a plain retry-driven spin: that frame drains the queue and falls
through on absence; mark-driven halt is decisive mid-stream — tokens after
the mark are never consumed.