bend-kit-crdt Releases (3): 0.2.0.0 0x509ae92f1a46e8598177a2eea991493f indexed https://jend.leeeet.dev/files.txt?path=bend-kit-crdt@0.2.0.0 0.1.1.0 0x3eab4b73ff9e01c6f814d7051d359eec unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-crdt@0.1.1.0 0.1.0.0 0x309d32ca05d5f636f2fa8ceda3071bc1 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-crdt@0.1.0.0 Definitions (56): Crdt.GCounter.new (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.new) # The counter with no increments. def GCounter.new() -> List<&2, U32>: Crdt.GCounter.get (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.get) # The count of replica i. def GCounter.get(s: List<&2, U32>, i: Nat) -> U32: Crdt.GCounter.merge (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.merge) # Component-wise maximum. It is commutative, associative, and idempotent. def GCounter.merge(a: List<&2, U32>, b: List<&2, U32>) -> List<&2, U32>: Crdt.GCounter.merge_all (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.merge_all) # The merge of every state in the list. def GCounter.merge_all(xs: List<&2, List<&2, U32>>) -> List<&2, U32>: Crdt.GCounter.pad (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.pad) # Zeros for replicas 0 to i - 1, then 1 for replica i. def GCounter.pad(i: Nat) -> List<&2, U32>: Crdt.GCounter.cons (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.cons) def GCounter.cons(c: U32, m: Maybe<&2, List<&2, U32>>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.inc.at (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.inc.at) # ok is false when n wrapped to 0. def GCounter.inc.at(ok: Bool, n: U32, t: List<&2, U32>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.inc (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.inc) # Adds 1 to the count of replica i. None when that count is 4294967295. def GCounter.inc(s: List<&2, U32>, i: Nat) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.add (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.add) def GCounter.add(m: Maybe<&2, U32>, +c: U32) -> Maybe<&2, U32>: Crdt.GCounter.value.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.value.go) def GCounter.value.go(s: List<&2, U32>, acc: Maybe<&2, U32>) -> Maybe<&2, U32>: Crdt.GCounter.value (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.value) # The sum of all counts. None when the sum does not fit in a U32. def GCounter.value(s: List<&2, U32>) -> Maybe<&2, U32>: Crdt.GCounter.le (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.le) # True when a is at most b in every entry. def GCounter.le(a: List<&2, U32>, b: List<&2, U32>) -> Bool: Crdt.GCounter.valid.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.valid.go) def GCounter.valid.go(t: List<&2, U32>, last: U32) -> Bool: Crdt.GCounter.valid (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.valid) # A valid state has no trailing 0, so each count vector has one form. def GCounter.valid(s: List<&2, U32>) -> Bool: Crdt.GCounter.size (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.size) def GCounter.size(s: List<&2, U32>) -> U32: Crdt.GCounter.to_cbor.items (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.to_cbor.items) def GCounter.to_cbor.items(s: List<&2, U32>) -> List<&1, Cbor.Val>: Crdt.GCounter.to_cbor (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.to_cbor) # A CBOR array of unsigned integers: the count of replica i is item i. def GCounter.to_cbor(s: List<&2, U32>) -> Cbor.Val: Crdt.GCounter.from_cbor.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor.word) def GCounter.from_cbor.word(ok: Bool, lo: U32, rest: Maybe<&2, List<&2, U32>>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.from_cbor.item (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor.item) def GCounter.from_cbor.item(v: Cbor.Val, rest: Maybe<&2, List<&2, U32>>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.from_cbor.items (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor.items) def GCounter.from_cbor.items(xs: List<&1, Cbor.Val>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.from_cbor.gate (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor.gate) def GCounter.from_cbor.gate(ok: Bool, s: List<&2, U32>) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.from_cbor.check (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor.check) def GCounter.from_cbor.check(m: Maybe<&2, List<&2, U32>>, +cap: U32) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.from_cbor (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.from_cbor) # A valid state with at most cap replicas, or None. def GCounter.from_cbor(v: Cbor.Val, +cap: U32) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.encode (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.encode) # Always Some: every item is an unsigned integer. def GCounter.encode(s: List<&2, U32>) -> Maybe<&1, Bytes.Bytes>: Crdt.GCounter.decode.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.decode.go) def GCounter.decode.go(m: Maybe<&1, Cbor.Val>, +cap: U32) -> Maybe<&2, List<&2, U32>>: Crdt.GCounter.decode (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=GCounter.decode) # CBOR bytes to a valid state with at most cap replicas, or None. def GCounter.decode(b: Bytes.Bytes, +cap: U32) -> Maybe<&2, List<&2, U32>>: Crdt.KCounter (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter) # A G-Counter keyed by replica IDs. A valid state lists IDs in ascending cmp # order, each with a count above 0. type KCounter<-K: Data> is Data: KNil{} KCon{id: K, count: U32, rest: KCounter} Crdt.KCounter.new (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.new) # The counter with no increments. def KCounter.new(-K: Data) -> KCounter: Crdt.KCounter.head (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.head) # cmp(x, first ID of b), or EQ when b is empty. def KCounter.head(~K: Data, ~cmp: K -> K -> Cmp, +x: K, b: KCounter) -> Cmp: Crdt.KCounter.heads (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.heads) # The comparison of the first IDs of a and b, or EQ when either is empty. def KCounter.heads(~K: Data, ~cmp: K -> K -> Cmp, a: KCounter, b: KCounter) -> Cmp: Crdt.KCounter.hit (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.hit) def KCounter.hit(c: Cmp, n: U32) -> U32: Crdt.KCounter.get (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.get) # The count of replica k: the largest count under an ID that cmp makes equal to k. def KCounter.get(~K: Data, ~cmp: K -> K -> Cmp, s: KCounter, +k: K) -> U32: Crdt.KCounter.merge.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.merge.go) # q is KCounter.heads(a, b). Passing it in lets match pick the step without closures. def KCounter.merge.go(~K: Data, ~cmp: K -> K -> Cmp, +a: KCounter, +b: KCounter, q: Cmp) -> KCounter: Crdt.KCounter.merge (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.merge) # The union of two ID-sorted states, with the maximum count where IDs are equal. def KCounter.merge(~K: Data, ~cmp: K -> K -> Cmp, +a: KCounter, +b: KCounter) -> KCounter: Crdt.KCounter.merge_all (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.merge_all) # The merge of every state in the list. def KCounter.merge_all(~K: Data, ~cmp: K -> K -> Cmp, xs: List<&2, KCounter>) -> KCounter: Crdt.KCounter.cons (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.cons) def KCounter.cons(-K: Data, k: K, c: U32, m: Maybe<&2, KCounter>) -> Maybe<&2, KCounter>: Crdt.KCounter.inc.at (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.inc.at) # ok is false when n wrapped to 0. def KCounter.inc.at(-K: Data, ok: Bool, x: K, n: U32, r: KCounter) -> Maybe<&2, KCounter>: Crdt.KCounter.inc.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.inc.go) # q is KCounter.head(k, s). def KCounter.inc.go(~K: Data, ~cmp: K -> K -> Cmp, s: KCounter, +k: K, q: Cmp) -> Maybe<&2, KCounter>: Crdt.KCounter.inc (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.inc) # Adds 1 to the count of replica k. None when that count is 4294967295. def KCounter.inc(~K: Data, ~cmp: K -> K -> Cmp, +s: KCounter, +k: K) -> Maybe<&2, KCounter>: Crdt.KCounter.value.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.value.go) def KCounter.value.go(-K: Data, s: KCounter, acc: Maybe<&2, U32>) -> Maybe<&2, U32>: Crdt.KCounter.value (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.value) # The sum of all counts. None when the sum does not fit in a U32. def KCounter.value(-K: Data, s: KCounter) -> Maybe<&2, U32>: Crdt.KCounter.le (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.le) # True when each count in a is at most the count of its ID in b. def KCounter.le(~K: Data, ~cmp: K -> K -> Cmp, a: KCounter, +b: KCounter) -> Bool: Crdt.KCounter.above (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.above) # True when s is empty or its first ID is above lo. def KCounter.above(~K: Data, ~cmp: K -> K -> Cmp, s: KCounter, +lo: K) -> Bool: Crdt.KCounter.valid (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.valid) # A valid state has strictly ascending IDs and no 0 count, so each counter has one form. def KCounter.valid(~K: Data, ~cmp: K -> K -> Cmp, s: KCounter) -> Bool: Crdt.KCounter.size (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.size) def KCounter.size(-K: Data, s: KCounter) -> U32: Crdt.KCounter.to_cbor.items (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.to_cbor.items) def KCounter.to_cbor.items(~K: Data, ~enc: K -> Cbor.Val, s: KCounter) -> List<&1, Cbor.Val & Cbor.Val>: Crdt.KCounter.to_cbor (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.to_cbor) # A CBOR map from each encoded ID to its count, in ID order. def KCounter.to_cbor(~K: Data, ~enc: K -> Cbor.Val, s: KCounter) -> Cbor.Val: Crdt.KCounter.from_cbor.word (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor.word) def KCounter.from_cbor.word(-K: Data, ok: Bool, mk: Maybe<&2, K>, lo: U32, rest: Maybe<&2, KCounter>) -> Maybe<&2, KCounter>: Crdt.KCounter.from_cbor.count (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor.count) def KCounter.from_cbor.count(-K: Data, v: Cbor.Val, mk: Maybe<&2, K>, rest: Maybe<&2, KCounter>) -> Maybe<&2, KCounter>: Crdt.KCounter.from_cbor.items (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor.items) def KCounter.from_cbor.items(~K: Data, ~dec: Cbor.Val -> Maybe<&2, K>, xs: List<&1, Cbor.Val & Cbor.Val>) -> Maybe<&2, KCounter>: Crdt.KCounter.from_cbor.gate (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor.gate) def KCounter.from_cbor.gate(-K: Data, ok: Bool, s: KCounter) -> Maybe<&2, KCounter>: Crdt.KCounter.from_cbor.check (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor.check) def KCounter.from_cbor.check(~K: Data, ~cmp: K -> K -> Cmp, m: Maybe<&2, KCounter>, +cap: U32) -> Maybe<&2, KCounter>: Crdt.KCounter.from_cbor (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.from_cbor) # A valid state with at most cap replicas, or None. dec reads one ID. def KCounter.from_cbor( ~K: Data, ~cmp: K -> K -> Cmp, ~dec: Cbor.Val -> Maybe<&2, K>, v: Cbor.Val, +cap: U32 ) -> Maybe<&2, KCounter>: Crdt.KCounter.encode (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.encode) # None only when enc gives a value with no CBOR form. def KCounter.encode(~K: Data, ~enc: K -> Cbor.Val, s: KCounter) -> Maybe<&1, Bytes.Bytes>: Crdt.KCounter.decode.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.decode.go) def KCounter.decode.go( ~K: Data, ~cmp: K -> K -> Cmp, ~dec: Cbor.Val -> Maybe<&2, K>, m: Maybe<&1, Cbor.Val>, +cap: U32 ) -> Maybe<&2, KCounter>: Crdt.KCounter.decode (https://jend.leeeet.dev/definition.txt?path=bend-kit-crdt@0.2.0.0/crdt.bend&name=KCounter.decode) # CBOR bytes to a valid state with at most cap replicas, or None. def KCounter.decode( ~K: Data, ~cmp: K -> K -> Cmp, ~dec: Cbor.Val -> Maybe<&2, K>, b: Bytes.Bytes, +cap: U32 ) -> Maybe<&2, KCounter>: