RetractResult

sealed class RetractResult<out T : Theory>

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()
}

Inheritors

Types

Link copied to clipboard
data class Failure<T : Theory>(val theory: T) : RetractResult<T>

A failed "retract" operation result, carrying the unchanged theory

Link copied to clipboard
data class Success<T : Theory>(val theory: T, val clauses: Iterable<Clause>) : RetractResult<T>

A successful "retract" operation result, carrying the new theory and removed clauses

Properties

Link copied to clipboard
abstract val clauses: Iterable<Clause>?

The clauses that were actually removed, in removal order; null if the operation isFailure.

Link copied to clipboard
abstract val firstClause: Clause?

Gets the first successfully retracted clause

Link copied to clipboard
open val isFailure: Boolean

Whether the retract operation removed no clause at all.

Link copied to clipboard
open val isSuccess: Boolean

Whether the retract operation removed at least one clause.

Link copied to clipboard
abstract val theory: T

The result always present value, is the clause database resulting from the operation execution