def stdio.loop

ezmcp@0.1.0.0 · src/io.bend:371

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

371# read, act on every whole line, and read again until stdin ends; `rev` is
372# the revision the next line is read by
373@unsafe def stdio.loop(
374  ~C: Data,
375  ~run: C -> String -> Value.Json -> IO(Rpc.Out),
376  ~srv: Server.Server,
377  +ctx: C,
378  buf: List<&2, U32>,
379  rev: String
380) -> IO(Unit):
381  IO.bind(Result<&1, &1, U32 & String, List<&2, U32>>, Unit,
382    ezmcp.stdin(stdio.chunk()),
383    res => stdio.got(C, run, srv, ctx, rev, buf,
384      rest => after => stdio.loop(C, run, srv, ctx, rest, after), res))

Uses (14)

Used by (1)