def slurp

ezx@1.11.0.0 · src/io/file.bend:41

import ezx@1.11.0.0/src/io/file.bend as File
import Base

41# the whole file, read in chunks until one is empty, or the fuel is
42def slurp(fuel: Nat, file: File, acc: String) -> IO(String):
43  match fuel:
44    case 0n:
45      slurp.end(file, acc)
46    case 1n+f:
47      do IO<String>:
48        got : File & Result<&1, &1, U32 & String, String> <- File.read(file, 65536)
49        slurp.next(got, acc, fl => a => slurp(f, fl, a))

Uses (11)

Used by (1)