def file.if

bend-kit-notch@0.4.0.0 · notch.bend:258

import bend-kit-notch@0.4.0.0/notch.bend as Notch
import Base

258# Write a stamped line and newline to a File; the returned handle must be kept or closed.
259# Below the logger's level, returns the same handle and Done without a clock read or write.
260def file.if(on: Bool, h: File, lg: Logger, lvl: Level, msg: String,
261  fs: List<&2, Field>) -> IO(File & Result<&1, &1, U32 & String, Unit>):
262  match on:
263    case True{}:
264      do IO<File & Result<&1, &1, U32 & String, Unit>>:
265        s : String <- stamp(lg, lvl, msg, fs)
266        File.write(h, s ++ "\n")
267    case False{}:
268      IO.pure(File & Result<&1, &1, U32 & String, Unit>, (h, Done{Unit{}}))

Uses (18)

Used by (1)