Wefts are like vector clocks – they offer causality information across different events in a
distributed system. A new weft is empty. Each site is then associated with an index, indicating
the index of the last operation received for that particular site.
For any two instances of Weft, an upper bound as well as a lower bound can be found. The lower
bound is the last known state to both wefts. The upper bound is the minimal state that could know
both wefts. This ability to find an upper or/and a lower bound is often referred to as a
semi-lattice.
Usually, these clocks are associated with some operations. There is, in general, no guarantee that a specific instance of weft is associated to an operation though.
To manage the operation indices for any site, use the get and insert functions.
The site identifiers can be any comparable type. This includes Int, Float, Time, Char,
String, and tuples or lists of comparable types.
Create a baseline that will always act as a proper lower bound for all the possible instances
of an Ordt.Weft.
-- joinLower clock empty == empty
-- joinUpper clock empty == clockCreate a weft that will contain only a single index for a given site.
-- joinLower (singleton "Alice" 1) empty == empty
-- joinUpper (singleton "Alice" 1) empty == singleton "Alice" 1Set the last operation index for a certain yarn.
Remove a yarn from a weft. If the key is not found, no changes are made.
Compare any two Weft instances. This comparison takes in consideration that two wefts might
not be comparable, in which case Order.EQ will be returned.
alice =
insert "Alice 3" empty
bob =
insert "Bob" 2 empty
-- compare empty alice == Order.LT
-- compare empty empty == Order.EQ
-- compare alice bob == Order.EQ
-- compare bob empty == Order.GTPerform a semi-lattice join on the lower bound of the two wefts.
Perform a semi-lattice join on the upper bound of the two wefts.
Represents a weft in a distributed system. So
Weft (Int)means that each site is identified by anInt, andWeft (String)that each site is identified by aString.