def write_all

stelliferous@0.0.2.0 · tensor_file.bend:345

import stelliferous@0.0.2.0/tensor_file.bend as TensorFile
import Base

345def write_all(fuel: Nat,writing: Writing) -> IO(Bool):
346  match fuel writing:
347    case 0n Pending{file,storage,offset,remaining}: finished(file,False{})
348    case 0n Finished{file,complete}: finished(file,complete)
349    case 1n+rest Finished{file,complete}: finished(file,complete)
350    case 1n+rest Pending{file,storage,+offset,+remaining}:
351      +count = Nat.min(U32.to_nat(chunk()),remaining)
352      do IO<Bool>:
353        next : Writing <- write_chunk(file,read_chunk(count,offset,storage,[]),count,remaining,offset)
354        write_all(rest,next)

Uses (12)

Used by (1)