def read_line.if
bend-stdio-pipes@0.2.0.0 · impl.bend:57
import bend-stdio-pipes@0.2.0.0/impl.bend as Impl
import Base
57def read_line.if(
58 file: File,
59 ended: Bool,
60 piece: String
61) -> IO(File & Result<&1, &1, U32 & String, Maybe<String>>):
62 match ended:
63 case True{}:
64 IO.pure(
65 File & Result<&1, &1, U32 & String, Maybe<String>>,
66 (file, Done{Some{read_line.unended(piece)}})
67 )
68 case False{}:
69 do IO<File & Result<&1, &1, U32 & String, Maybe<String>>>:
70 next: File & Result<&1, &1, U32 & String, String> <- File.read_line(file, 1)
71 return read_line.peeked(next, piece)