def sys.write.opened

ezsys@0.1.0.0 · src/sys.bend:117

import ezsys@0.1.0.0/src/sys.bend as Sys
import Base

117# write to an opened file; a failed open is the answer
118def sys.write.opened(
119  text: String,
120  res: Result<&1, &1, U32 & String, File>
121) -> IO(Result<&1, &1, U32 & String, Unit>):
122  match res:
123    case Fail{error}:
124      IO.pure(Result<&1, &1, U32 & String, Unit>, Fail{error})
125    case Done{file}:
126      IO.bind(File & Result<&1, &1, U32 & String, Unit>,
127        Result<&1, &1, U32 & String, Unit>, File.write(file, text),
128        sys.write.done)

Uses (11)

Used by (1)