def replay.go
bend-kit-journal@0.3.1.0 · journal.bend:137
import bend-kit-journal@0.3.1.0/journal.bend as Journal
import Base
137
138def replay.go(~P: Type, ~S: Type, ~A: 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, ~step: A -> P -> A, n: Nat, +max: U32, st: Step<P, S>, acc: A) -> Replay<A, S>:
139 match n st:
140 case 0n End{s}:
141 Replay{acc, Clean{}, s}
142 case 0n Short{s}:
143 Replay{acc, Torn{}, s}
144 case 0n Bad{why, s}:
145 Replay{acc, Corrupt{why}, s}
146 case 0n Got{p, s}:
147 Replay{step(acc, p), Corrupt{"frame budget exhausted"}, s}
148 case 1n+m End{s}:
149 Replay{acc, Clean{}, s}
150 case 1n+m Short{s}:
151 Replay{acc, Torn{}, s}
152 case 1n+m Bad{why, s}:
153 Replay{acc, Corrupt{why}, s}
154 case 1n+m Got{p, s}:
155 replay.go(~P, ~S, ~A, ~fits, ~u32, ~cut, ~skip, ~sum, ~step, m, max, next(~P, ~S, ~fits, ~u32, ~cut, ~skip, ~sum, max, s), step(acc, p))