def fold_loop
bend-collections@1.0.0.0 · src/containers/internal/intrusive_list.bend:151
import bend-collections@1.0.0.0/src/containers/internal/intrusive_list.bend as IntrusiveList
import Base
import bend-collections@1.0.0.0/src/containers/types/intrusive_doubly_linked_list.bend as E
151def fold_loop(~S: Type, ~N: Data, ~V: Data, ~A: Type, ~C: Data, ~next: S -> N -> S & Maybe<&2, N>, ~value: S -> N -> S & V, ~fn: S -> C -> A -> V -> S & A, +fuel: Nat, +c: C, r: S & (Maybe<&2, N> & A)) -> S & Result<&2, &1, E.Error, A>:
152 match fuel r:
153 case _ Tuple{s, Tuple{None{}, acc}}: (s, Done{acc})
154 case 0n Tuple{s, Tuple{Some{node}, acc}}: (s, Fail{E.LimitExceeded{}})
155 case 1n+p Tuple{s, Tuple{Some{node}, acc}}:
156 fold_loop(~S, ~N, ~V, ~A, ~C, ~next, ~value, ~fn, p, c, fold_step(~S, ~N, ~V, ~A, ~C, ~next, ~value, ~fn, s, node, c, acc))