def wait
import cswap-bend-cli@0.1.0.0/lock.bend as Lockimport Base
import cswap-bend-cli@0.1.0.0/fs.bend as Fs
37# Retry `fuel` more times, 100 ms apart, until the lock is held.
38def wait(fuel: Nat, fr: File & Fs.Res(Bool)) -> IO(File & Fs.Res(Bool)):
39 match fuel fr:
40 case 1n++p Tuple{f, Done{False{}}}:
41 IO.bind(Unit, File & Fs.Res(Bool), IO.sleep(poll_ms()),
42 u => IO.bind(File & Fs.Res(Bool), File & Fs.Res(Bool), attempt(f), r => wait(p, r)))
43 case _ _:
44 IO.pure(File & Fs.Res(Bool), fr)