This module implements types and functions to build, find, get values from, and compare nodes
Node can be either a branch or leaf Node
with optional
data or a Tombstone
representing a removed Node
Represents an Error updating a node
value : Node a -> Maybe a
Return the value of a node
value (node 'a' [0, 1]) == Just 'a'
value (tombstone [0, 1]) == Nothing
timestamp : Node a -> Basics.Int
Return the timestamp of a node
timestamp (node 'a' [0, 1]) == 1
path : Node a -> List Basics.Int
Return the path of a node
path (node (Just 'a') [0, 1]) == [0, 1]
isDeleted : Node a -> Basics.Bool
Return True
if the node has been deleted
children : Node a -> List (Node a)
Return a list of a nodes' children
descendant : List Basics.Int -> Node a -> Maybe (Node a)
Return a Node at a path
init : a -> List Basics.Int -> Node a
Build a node
timestamp (init 'a' [0, 1]) == 1
path (init 'a' [0, 1]) == [0, 1]
value (init 'a' [0, 1]) == Just 'a'
root : Node a
Build a root node
timestamp root == 0
path root == []
value root == Nothing
tombstone : List Basics.Int -> Node a
Build a tombstone providing timestamp and path
timestamp (tombstone [0, 1]) == 1
path (tombstone [0, 1]) == [0, 1]
value (tombstone [0, 1]) == Nothing
addAfter : Basics.Int -> ( Basics.Int, a ) -> Node a -> Result Error (Node a)
Adds after node with timestamp
delete : Basics.Int -> Node a -> Result Error (Node a)
Delete a node
updateParent : Basics.Int -> Node a -> (Node a -> Result Error (Node a)) -> Result Error (Node a)
Update a node with a successful result