def recover.go

bend-kit-journal@0.3.1.0 · journal.bend:112

import bend-kit-journal@0.3.1.0/journal.bend as Journal
import Base

112# Every frame from st on. Once n frames are taken, the next one is the last: the tail is Corrupt,
113# and rest starts after it. Callers give n at least the frame count, so this never happens.
114def recover.go(~a: Quant, ~P: Kind(a), ~S: Type, ~fits: S -> @+at:U32 -> @+n:U32 -> S & Bool, ~u32: S -> @+at:U32 -> S & U32, ~cut: S -> @+hs:U32 -> @+len:U32 -> S & P, ~skip: S -> @+hs:U32 -> @+len:U32 -> S, ~sum: P -> P & U32, n: Nat, +max: U32, st: Step<P, S>) -> Recovery<a, P, S>:
115  match n st:
116    case 0n End{s}:
117      Recovery{Nil{}, Clean{}, s}
118    case 0n Short{s}:
119      Recovery{Nil{}, Torn{}, s}
120    case 0n Bad{why, s}:
121      Recovery{Nil{}, Corrupt{why}, s}
122    case 0n Got{p, s}:
123      Recovery{Con{p, Nil{}}, Corrupt{"frame budget exhausted"}, s}
124    case 1n+m End{s}:
125      Recovery{Nil{}, Clean{}, s}
126    case 1n+m Short{s}:
127      Recovery{Nil{}, Torn{}, s}
128    case 1n+m Bad{why, s}:
129      Recovery{Nil{}, Corrupt{why}, s}
130    case 1n+m Got{p, s}:
131      recover.con(~a, ~P, ~S, p, recover.go(~a, ~P, ~S, ~fits, ~u32, ~cut, ~skip, ~sum, m, max, next(~P, ~S, ~fits, ~u32, ~cut, ~skip, ~sum, max, s)))

Uses (10)

Used by (1)