maca/crdt-replicated-tree/1.1.0

NOTE: the latest version is 5.0.0

Formerly maca/crdt-replicated-graph. Search finds this package by either name.

CRDTree.Node

This module implements types and functions to build, find, get values from, and compare nodes

type Node a

Node can be either a branch or leaf Node with optional data or a Tombstone representing a removed Node

Properties

value : Node a -> Maybe a

Return the value of a node

value (node (Just 'a') [0, 1]) == Just 'a'
value (tombstone [0, 1]) == Nothing
timestamp : Node a -> Int

Return the timestamp of a node

timestamp (node (Just 'a') [0, 1]) == 1
path : Node a -> List Int

Return the path of a node

path (node (Just 'a') [0, 1]) == [0, 1]
isDeleted : Node a -> Bool

Return True if the node has been deleted

Traverse

children : Node a -> List (Node a)

Return a list of a nodes' children

descendant : List Int -> Node a -> Maybe (Node a)

Return a Node at a path

Build

init : a -> List Int -> Node a

Build a node

timestamp (node (Just 'a') [0, 1]) == 1
path (node (Just 'a') [0, 1]) == [0, 1]
value (node (Just 'a') [0, 1]) == Just 'a'

Build a root node

timestamp root == 0
path root == []
value root == Nothing
tombstone : List 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

Update

updateChildren : List (Node a) -> Node a -> Node a

Update a Node's children