RetractResult
The outcome of a Theory.retract/Theory.retractAll operation: either Success, carrying the resulting theory and the clauses that were actually removed, or Failure, carrying the theory unchanged because no clause matched. Modelled as a sealed hierarchy (rather than, say, a nullable result) so that callers must handle both cases explicitly, mirroring how Prolog's own retract/1 can succeed or simply fail.
when (val result = theory.retract(someClause)) {
is RetractResult.Success -> useNewTheory(result.theory)
is RetractResult.Failure -> reportNothingRemoved()
}Content copied to clipboard