def file.slurp

snap@1.4.0.0 · src/file.bend:40

import snap@1.4.0.0/src/file.bend as File
import Base

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

Uses (11)

Used by (1)