Class PartialOrdering

java.lang.Object
org.ek9lang.compiler.support.PartialOrdering
All Implemented Interfaces:
BiFunction<ISymbol, ISymbol, Optional<String>>

public final class PartialOrdering extends Object implements BiFunction<ISymbol, ISymbol, Optional<String>>
THE answer to "is this type's <=> PARTIAL?" - unset for some pair of SET values of the type - given as the wording of why, to follow "'X' ...", or empty when it is total (so "is partial" is apply(...).isPresent()). Hold one and apply it with the Any type. Two kinds, and only two:
  • a PARTIAL BUILT-IN (IsPartialBuiltIn): defined only within a group of its own values and unset between groups (a currency for Money, a unit suffix for Dimension);
  • a developer's type whose values can be of DIFFERENT run-time types under a per-type sameness - an open or abstract class, record or component, or a trait, with no <=> written by hand on an abstract base or trait (MayMixRuntimeTypes, the test behind E07187): two values of different run-time types have an unset <=> (D24 rule 3; Steve, 2026-10-27, "extend E07188"). Whether a sub-type exists yet is not asked - as for E07187, a later module can add one.

The built-in kind is DECLARED by the type implementing org.ek9.lang.ComparisonGroup in the runtime; the compiler reads that declaration, it never lists type names (Steve, 2026-10-21, sameness stock-take 4.4: "the only partial built-ins are Money and Dimension, declared on the type"). Only that kind gets phase 7's unset case for <? and >? (IsPartialBuiltIn); the other kind is refused there by E07187.

Every other <=> is TOTAL: it orders every two SET values. A user type's own is judged separately - a hand-written one by phase5/OrderingTotality (E07188, which asks this of each <=> it is built on), a defaulted one by OrderingAvailability.orderingSurvives(MethodSymbol, ISymbol), which fails when a field's type is partial.

Never test for Money or Dimension by name or class in the compiler - a new built-in with this property implements the interface and this class sees it.

  • Constructor Details

    • PartialOrdering

      public PartialOrdering()
  • Method Details

    • apply

      public Optional<String> apply(ISymbol type, ISymbol ek9Any)
      THE wording of why a type's <=> is partial, to follow "'X' ...", or empty when it is total: a partial built-in, or a type whose values may be of different run-time types under a per-type sameness. A generic's bare T is never judged here (it is judged where it is substituted, or left to the run time).
      Specified by:
      apply in interface BiFunction<ISymbol, ISymbol, Optional<String>>
      Parameters:
      type - the type asked about, may be null
      ek9Any - the Any type
      Returns:
      the reason, if its <=> is partial