def ask
import bend-kit-runner@0.13.0.1/runner.bend as Runnerimport Base
1164# Sends m, built with a new reply channel, on the inbox and waits for the reply.
1165def ask(-A: Data, -X: Type, +ib: Chan(Msg<A>), m: Chan(Out(X)) -> Msg<A>) -> IO(Out(X)):
1166 do IO<Out(X)>:
1167 +rep : Chan(Out(X)) <- Chan.new(Out(X), 1)
1168 x : Result<&1, &1, Msg<A>, Unit> <- Chan.send(Msg<A>, ib, m(rep))
1169 ask.sent(A, X, x, rep)