Io.write.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend as Io Lines 305-371 of mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&start_line=305&end_line=371 import Base import mylsm-lsm-store@0.6.0.1/src/coordinator/Protocol.bend as Protocol def write.loop( fuel: Nat, state: WriteState ) -> IO( File & Result<&1, &1, U32 & String, Unit> ): match fuel: case 0n: match state: case WriteNeed{file, _, _, _, _}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(7, "socket write exhausted its progress bound")})) case WriteSent{pair, _, _, _}: match pair: case (file, _): IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(7, "socket write exhausted its progress bound")})) case WriteAdvance{file, _, _, _, _, _}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(7, "socket write exhausted its progress bound")})) case WriteFailed{file}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(5, "socket write made no progress")})) case WriteDone{file}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Done{Unit{}})) case WriteSend{file, _, _, _, _}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(7, "socket write exhausted its progress bound")})) case 1n+rest: match state: case WriteNeed{file, remaining, total, offsets, bytes}: match remaining: case (remaining_check, (remaining_send, _)): write.loop(rest, write.need(U32.is_eq(remaining_check, 0), file, remaining_send, total, offsets, bytes)) case WriteDone{file}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Done{Unit{}})) case WriteFailed{file}: IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{(5, "socket write made no progress")})) case WriteSend{file, total, offset, remaining, words}: match offset: case (offset_send, (offset_keep, _)): match remaining: case (remaining_send, (remaining_keep, _)): do IO>: pair : File & Result<&1, &1, U32 & String, U32 & Array> <- write.words(file, offset_send, write.chunk(remaining_send), words) write.loop(rest, WriteSent{pair, total, offset_keep, remaining_keep}) case WriteSent{pair, total, offset, remaining}: match pair: case (file, Fail{error}): IO.pure(File & Result<&1, &1, U32 & String, Unit>, (file, Fail{error})) case (file, Done{(sent, words)}): write.loop(rest, WriteAdvance{file, total, offset, remaining, Protocol.u32.duplicate.triple(sent), words}) case WriteAdvance{file, total, offset, remaining, copies, words}: match copies: case (sent_check, (sent_offset, sent_remaining)): write.loop(rest, write.advance(U32.is_eq(sent_check, 0), file, total, offset, remaining, sent_offset, sent_remaining, words)) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&name=WriteState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&name=write.advance https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&name=write.chunk https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&name=write.need https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Io.bend&name=write.words https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/coordinator/Protocol.bend&name=u32.duplicate.triple