def handle
bend-kit-runner@0.13.0.1 · runner.bend:1393
import bend-kit-runner@0.13.0.1/runner.bend as Runner
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
1393
1394def handle(~A: Data, ~penc: A -> Bytes.Bytes, m: Msg<A>, +now: Nat, +rnd: Nat, r: Runner<A>, err: Out(Unit),
1395 next: Runner<A> -> Nat -> Out(Unit) -> IO(Runner<A> & Out(Bool))) -> IO(Runner<A> & Out(Bool)):
1396 match m:
1397 case Ended{+id, +o}:
1398 settle(~A, ~penc, id, o, now, rnd, r, err, (r2 => e2 => next(r2, 0n, e2)))
1399 case Add{+d, x, +rep}:
1400 IO.bind(Runner<A> & Out(Nat), Runner<A> & Out(Bool), enqueue(~A, ~penc, r, d, x), y => added(A, rep, y, err, next))
1401 case Drop{+i, +rep}:
1402 IO.bind(Ran(A), Runner<A> & Out(Bool), cancel(~A, ~penc, r, i), y => dropped(A, rep, y, err, next))