def Drive.fed

bend-trace-context@0.2.0.0 · trace_context.bend:953

import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base

953# The driver of the three machines: a trace ID draw, a span ID draw and a
954# generation. It feeds a machine one source word at a time while the
955# machine's step waits for one, and stops as soon as it has ended. Each
956# machine gives, as templates, `waiting`, the draw that a step feeds its next
957# word to, if it waits for one, and `feed`, the step after that word. The
958# driver keeps each step beside what `waiting` says of it.
959#
960# Feed a word that a source returned, keeping the source's next state.
961def Drive.fed(~T: Data, ~D: Data, ~waiting: T -> Maybe<&2, D>, ~feed: Result<&1, &1, U32 & String, U32> -> D -> T,
962  -S: Type, got: S & Result<&1, &1, U32 & String, U32>, draw: D) -> S & (T & Maybe<&2, D>):
963  (state, word) = got
964  +next = feed(word, draw)
965  (state, (next, waiting(next)))

Uses (6)

Used by (2)