None
PL
Shelf: easy way for recursive CRDT documents
[]
Bartosz Sypytkowski
[<Struct>] type Shelf<'t when 't : comparison> = { value: Node<'t> version: int } // used for conflict resolution and Node<'t when 't : comparison> = | Value of 't | Object of Map<string, Shelf<'t>> module Shelf //NOTE: deeply nested shelf updates will increment version on all // nodes on a path from the document root down to the leaf let set v shelf = { value = v; version = shelf.version + 1 } module Shelf let rec merge a b = let cmp = a.version.CompareTo(b.version) if cmp > 0 then a elif cmp < 0 then b else match a.value, b.value with // objects takes precedence over scalar values | Object _, Value _ -> a | Value _, Object _ -> b // scalar values are compared against each other - greater one wins | Value ma, Value mb -> if mb > ma then b else a // recursively merge objects entries |…