def stdio.lines

ezmcp@0.1.0.0 · src/io.bend:300

import ezmcp@0.1.0.0/src/io.bend as Io
import Base
import emerging-ezjson@1.2.0.0/src/value.bend as Value
import ezmcp@0.1.0.0/src/rpc.bend as Rpc
import ezmcp@0.1.0.0/src/server.bend as Server
import ezmcp@0.1.0.0/src/line.bend as Line

300# every whole line, in order, each read by the revision the line before it
301# left; answers the revision the last one left
302def stdio.lines(
303  ~C: Data,
304  ~run: C -> String -> Value.Json -> IO(Rpc.Out),
305  ~srv: Server.Server,
306  +ctx: C,
307  lines: List<&2, List<&2, U32>>,
308  +rev: String
309) -> IO(String):
310  match lines:
311    case []:
312      IO.pure(String, rev)
313    case line <> rest:
314      stdio.turn(C, run, ctx, rev, Line.line(srv, rev, line),
315        after => stdio.lines(C, run, srv, ctx, rest, after))

Uses (10)

Used by (2)