Lattice

kofre.base.Lattice
See theLattice companion object
@FunctionalInterface
trait Lattice[A]

A lattice describes a set of values where we always can merge two values and get a “consistent” result. Technically, this is a join semilattice. See also Bottom.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def merge(left: A, right: A): A

By assumption: associative, commutative, idempotent.

By assumption: associative, commutative, idempotent.

Implementation note: If it matters, assume that left is the current state and right is an added delta. All code should assume that left is the larger state (and optimize for this). If left == right, prefer to return left.

Attributes

Concrete methods

def decompose(a: A): Iterable[A]

Decompose a state into potentially smaller parts. Guarantees for any two states a and b that decompose(a).fold(b)(merge) == b merge a, i.e., merging the decomposed values into b has the same result as merging the full a into b (assuming b is normalized).

Decompose a state into potentially smaller parts. Guarantees for any two states a and b that decompose(a).fold(b)(merge) == b merge a, i.e., merging the decomposed values into b has the same result as merging the full a into b (assuming b is normalized).

Note that the goal here is small individual storage size at reasonable computational cost. Minimalism of returned results is not guaranteed. It is also not guaranteed that the result does not overlap. The result may be the empty sequence.

Attributes

def diff(state: A, delta: A): Option[A]

Computes delta without state. Overriding this is discouraged.

Computes delta without state. Overriding this is discouraged.

Attributes

def lteq(left: A, right: A): Boolean

Lattice order is derived from merge, but should be overridden for efficiency

Lattice order is derived from merge, but should be overridden for efficiency

Attributes

def normalize(v: A): A

Some types have multiple structural representations for semantically the same value, e.g., they may contain redundant or replaced parts. This can lead to semantically equivalent values that are not structurally equal. Normalize tries to fix this. Overriding this is discouraged.

Some types have multiple structural representations for semantically the same value, e.g., they may contain redundant or replaced parts. This can lead to semantically equivalent values that are not structurally equal. Normalize tries to fix this. Overriding this is discouraged.

Attributes

Extensions

Extensions

extension (left: A)
final infix inline def <=(right: A): Boolean

Convenience extensions for the above.

Convenience extensions for the above.

Attributes

final inline def decomposed: Iterable[A]

Convenience extensions for the above.

Convenience extensions for the above.

Attributes

final infix inline def merge(right: A): A

Convenience extensions for the above.

Convenience extensions for the above.

Attributes