# CRDTs in Unison livestream notes Compiled by: QQQ * Paul Chiusano * Add your name here if you contribute to these notes 🙏 ## What is a CRDT? Lingo: * "Eventual consistency" * State-based * Join semilattice * Operation-based * Delta-based ### Basic example: a `Set a` with just `insert` More generally, the thing we need is a "join semilattice" ```haskell= Set.insert : a -> Set a -> Set Set.union : Set a -> Set a -> Set a -- idempotence -- forall s . -- Set.union s s == s -- commutative -- forall s s2 : -- Set.union s s2 == Set.union s2 s -- -- associative -- Set.union s1 (Set.unison s2 s3) == -- Set.union (Set.union s1 s2) s3 -- Set.subset : Set a -> Set a -> Boolean -- {1,2,3} `subset` {1,2,3,4} -- -- Set.subset s (Set.insert x s) ``` Another example is a `Nat` with just `increment`. Alice does: initial state: 0 increment 1 increment 2 increment 7 Bob does: initial state: 0 increment 2 increment 4 increment 9 sync ### "Journal CRDT" A cons-list that also supports random access reads. ## Bugs to track down later ``` .> find : Optional a ->{Abort} a ☝️ I couldn't find exact type matches, resorting to fuzzy matching... 😶 No results. Check your spelling, or try using tab completion to supply command arguments. .> find toAbort 1. basedev.Optional.toAbort : Optional a ->{Abort} a ``` ``` unison: can't serialize term with blanks CallStack (from HasCallStack): error, called at src/Unison/Codebase/SqliteCodebase/Conversions.hs:122:26 in unison-parser-typechecker-0.0.0-A8ttdqm3h8zHOX6a04YWny:Unison.Codebase.SqliteCodebase.Conversions ``` ## Things to think about Is the "reorder segments past the LCA arbitrarily" approach to join actually associative.
{"metaMigratedAt":"2023-06-16T04:27:54.687Z","metaMigratedFrom":"Content","title":"CRDTs in Unison livestream notes","breaks":true,"contributors":"[{\"id\":\"5c318b49-4f97-43ed-aa55-2caf9ba9634c\",\"add\":1732,\"del\":4}]"}
Expand menu