def KCounter.inc.go
bend-kit-crdt@0.2.0.0 · crdt.bend:282
import bend-kit-crdt@0.2.0.0/crdt.bend as Crdt
import Base
282
283def KCounter.inc.go(~K: Data, ~cmp: K -> K -> Cmp, s: KCounter<K>, +k: K, q: Cmp) -> Maybe<&2, KCounter<K>>:
284 match s q:
285 case KNil{} _:
286 Some{KCon{k, 1, KNil{}}}
287 case KCon{+x, +c, +r} LT{}:
288 Some{KCon{k, 1, KCon{x, c, r}}}
289 case KCon{+x, +c, +r} EQ{}:
290 KCounter.inc.at(K, U32.is_lt(c, U32.inc(c)), x, U32.inc(c), r)
291 case KCon{+x, +c, +r} GT{}:
292 KCounter.cons(K, x, c, KCounter.inc.go(~K, ~cmp, r, k, KCounter.head(~K, ~cmp, k, r)))