Documentation ¶
Index ¶
Constants ¶
const ( ErrMsgTypeMismatch = "type mismatch (%T vs %T)" ErrMsgTupleLengthMismatch = "tuple length mismatch (%d vs %d)" ErrMsgDistinctSingletons = "distinct singletons (%v vs %v)" ErrMsgAtTupleIndex = "at tuple index %d: %v" ErrMsgAtMapKey = "at map key %q: %v" ErrMsgNonInclusiveBitSets = "non-inclusive bit sets (%#x vs %#x)" ErrMsgContradictingOrders = "combining contradicting orders (%d && %d)" ErrMsgStringListElemMismatch = "at string list index %d: distinct values (%q vs %q)" )
const (
ErrMsgAutoTypeWithoutKey = "auto type but not defined as a key"
)
Please ensure this list is synchronized with the order of Tuple{} in encodeFieldTypeToLattice().
Variables ¶
This section is empty.
Functions ¶
func CombineCompareResult ¶
CombineCompareResult combines two comparison results.
Types ¶
type BitSet ¶
type BitSet uint
BitSet is a set of bits where `a < b` iff `a` is a subset of `b`.
type Equality ¶
type Equality interface { // Equals returns true if this instance should be equal to another object. Equals(other Equality) bool }
Equality allows custom equality.
type IncompatibleError ¶
type IncompatibleError struct { Msg string Args []interface{} }
func (*IncompatibleError) Error ¶
func (e *IncompatibleError) Error() string
type Int64 ¶
type Int64 int64
Int64 is an int64 implementing Lattice.
type Lattice ¶
type Lattice interface { // Unwrap returns the underlying object supporting the lattice. This // operation is deep. Unwrap() interface{} // Compare this instance with another instance. // // Returns -1 if `self < other`, 0 if `self == other`, 1 if `self > other`. // Returns `IncompatibleError` if the two instances are not ordered. Compare(other Lattice) (int, error) // Join finds the "least upper bound" of two Lattice instances. The result // is `>=` both inputs. Returns an error if the join does not exist. Join(other Lattice) (Lattice, error) }
Lattice is implemented for types which forms a join-semilattice.
func EqualitySingleton ¶
EqualitySingleton wraps an unordered value with equality defined by custom code instead of the `==` operator.
func MaybeSingletonInterface ¶
func MaybeSingletonInterface(value interface{}) Lattice
MaybeSingletonInterface is a convenient function calling `Maybe(Singleton(value))`.
func MaybeSingletonString ¶
MaybeSingletonString is a convenient function calling `Maybe(Singleton(s))`.
type LatticeMap ¶
type LatticeMap interface { // New creates an empty LatticeMap of the same type as the receiver. New() LatticeMap // Insert inserts a key-value pair into the map. Insert(key string, value Lattice) // Get obtains the Lattice object at the given key. Returns nil if the key // does not exist. Get(key string) Lattice // ForEach iterates the map. ForEach(func(key string, value Lattice) error) error // CompareWithNil returns the comparison result when the value is compared // with a non-existing entry. CompareWithNil(value Lattice) (int, error) // JoinWithNil returns the result when the value is joined with a // non-existing entry. If the joined result should be non-existing, this // method should return nil, nil. JoinWithNil(value Lattice) (Lattice, error) // ShouldDeleteIncompatibleJoin returns true if two incompatible entries // should be deleted instead of propagating the error. ShouldDeleteIncompatibleJoin() bool }
LatticeMap is a map of Lattice objects keyed by strings.
type StringList ¶
type StringList []string
StringList is a list of string where `a <= b` iff `a == b[:len(a)]`.
func (StringList) Compare ¶
func (a StringList) Compare(other Lattice) (int, error)
Compare implements Lattice.
type Tuple ¶
type Tuple []Lattice
Tuple of Lattice instances. Given two Tuples `a` and `b`, we define `a <= b` iff `a[i] <= b[i]` for all `i`.