| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Free.Agent.Seat
Description
Free seat syntax: pipelines and hosts as inspectable terms that fold into
AgentShard values, with STM agents via
interpretSeatS.
Synopsis
- data FreeSeat where
- SeatPipeline :: Pipeline (Post Text) (Post Text) -> FreeSeat
- SeatHost :: Host -> FreeSeat
- SeatSilent :: FreeSeat
- SeatCompose :: FreeSeat -> FreeSeat -> FreeSeat
- SeatFork :: FreeSeat -> FreeSeat
- SeatAwait :: FreeSeat -> FreeSeat -> FreeSeat
- SeatRace :: FreeSeat -> FreeSeat -> FreeSeat
- SeatFanOut :: [FreeSeat] -> FreeSeat
- SeatFanIn :: ([[Post Text]] -> [Post Text]) -> [FreeSeat] -> FreeSeat
- type SeatBehaviour = [Post Text] -> [Post Text]
- interpretSeat :: FreeSeat -> AgentShard [Post Text] [Post Text]
- interpretSeatA :: FreeSeat -> SeatBehaviour
- interpretSeatS :: FreeSeat -> AgentSBox
- runAgentSBox :: AgentSBox -> [Post Text] -> IO [Post Text]
- pipelineSeat :: Pipeline (Post Text) (Post Text) -> FreeSeat
- hostSeat :: Host -> FreeSeat
- silentSeat :: FreeSeat
- forkSeat :: FreeSeat -> FreeSeat
- awaitSeat :: FreeSeat -> FreeSeat -> FreeSeat
- raceSeat :: FreeSeat -> FreeSeat -> FreeSeat
- fanOutSeat :: [FreeSeat] -> FreeSeat
- fanInSeat :: ([[Post Text]] -> [Post Text]) -> [FreeSeat] -> FreeSeat
- bundleSeat :: ([[Post Text]] -> [Post Text]) -> [FreeSeat] -> FreeSeat
Documentation
An inspectable '[Post Text]'-to-'[Post Text]' seat term.
SeatPipeline— a pure list-to-list pipeline overPost.SeatHost— a one-shot host (may perform IO).SeatSilent— emits nothing and clears the buffer.SeatCompose— sequential composition of seats.SeatFork— syntactic marker that the input state is duplicated.SeatAwait— product tensor: both branches speak on the same input.SeatRace— coproduct tensor: left-biased race of branch emits.SeatFanOut— run every branch on a copy of the input, concatenate.SeatFanIn— fan-out then collapse the branch outputs with a summary.
Constructors
| SeatPipeline :: Pipeline (Post Text) (Post Text) -> FreeSeat | A pure pipeline stage. |
| SeatHost :: Host -> FreeSeat | A one-shot host stage (may perform IO). |
| SeatSilent :: FreeSeat | The silent seat: emits the empty list. |
| SeatCompose :: FreeSeat -> FreeSeat -> FreeSeat | Sequential composition of seats. |
| SeatFork :: FreeSeat -> FreeSeat | Fork the current input session (semantically identity at this stage). |
| SeatAwait :: FreeSeat -> FreeSeat -> FreeSeat | Product / await: concatenate the emits of both branches. |
| SeatRace :: FreeSeat -> FreeSeat -> FreeSeat | Coproduct / race: left emit wins if non-empty, otherwise right. |
| SeatFanOut :: [FreeSeat] -> FreeSeat | Fan-out: run every branch on a copy of the input. |
| SeatFanIn :: ([[Post Text]] -> [Post Text]) -> [FreeSeat] -> FreeSeat | Fan-in: fan-out then summarize the collected branch outputs. |
type SeatBehaviour = [Post Text] -> [Post Text] Source #
Pure behaviour semantics of a free seat: a function from committed posts to emitted posts.
This is the specification-domain interpretation. Pipelines are list
transducers; SeatAwaitSeatRaceSeatFanOut/SeatFanIn are the bundle
tensors; SeatFork is identity. SeatHost is not pure and raises a runtime
error.
interpretSeat :: FreeSeat -> AgentShard [Post Text] [Post Text] Source #
Fold a free seat term into an agent shard by interpreting each generator
and composing the resulting shards with composeEnds0.
The buffer state is carried by the base arrow ('Body (,) (K IO) [Post Text]') rather than a monad transformer.
interpretSeatA :: FreeSeat -> SeatBehaviour Source #
Fold a free seat term into its pure behaviour.
The result is independent of any effectful boundary; it is the function that the shard interpretation realises.
interpretSeatS :: FreeSeat -> AgentSBox Source #
Fold a free seat term into an STM agent.
Hosts are not STM-pure and raise a runtime error. All other constructors are interpreted as one-post-at-a-time STM agents whose state is hidden inside the returned box.
runAgentSBox :: AgentSBox -> [Post Text] -> IO [Post Text] Source #
Run an STM-agent box over a list of posts, returning only the emitted
posts. The state is sealed inside the box; the caller sees the same
list-to-list interface as interpretSeatA.
pipelineSeat :: Pipeline (Post Text) (Post Text) -> FreeSeat Source #
Lift a pure pipeline into a free seat term.
silentSeat :: FreeSeat Source #
The silent seat: emits nothing.
forkSeat :: FreeSeat -> FreeSeat Source #
Mark a seat as running on a forked copy of the input session.
fanOutSeat :: [FreeSeat] -> FreeSeat Source #
Fan-out: run every seat on a copy of the input.