def file.read.opened

snap@1.4.0.0 · src/file.bend:82

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

82# what an opened file holds, or nothing when it would not open
83def file.read.opened(res: Result<&1, &1, U32 & String, File>) -> IO(Maybe<&2, String>):
84  match res:
85    case Fail{_e}:
86      IO.pure(Maybe<&2, String>, None{})
87    case Done{file}:
88      do IO<Maybe<&2, String>>:
89        got : File & Result<&1, &1, U32 & String, U32> <- File.size(file)
90        text : String <- file.read.sized(got)
91        return Some{text}

Uses (11)

Used by (1)