asJoinPartialOrder method

PartialOrder<T> asJoinPartialOrder(
  1. Eq<T> eq
)

Given Eq<T>, return a PartialOrder<T> using the combine operator of Semilattice to determine the partial ordering. This method assumes combine functions as join (that is, as an upper bound).

This method returns:

  • 0.0 if x == y
  • -1.0 if y == combine(x, y)
  • 1.0 if x == combine(x, y)
  • null otherwise

Implementation

PartialOrder<T> asJoinPartialOrder(Eq<T> eq) => PartialOrder.from(
      (x, y) {
        if (eq.eqv(x, y)) {
          return 0;
        }

        final z = combine(x, y);
        return eq.eqv(y, z)
            ? -1
            : eq.eqv(x, z)
                ? 1
                : null;
      },
    );