commonMain.it.unibo.tuprolog.theory.RetractResult.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of theory-metadata Show documentation
Show all versions of theory-metadata Show documentation
In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses
package it.unibo.tuprolog.theory
import it.unibo.tuprolog.core.Clause
import kotlin.js.JsName
/** A result given after a "retract" operation */
sealed class RetractResult {
/** The result always present value, is the clause database resulting from the operation execution */
@JsName("theory")
abstract val theory: Theory
/** A successful "retract" operation result, carrying the new [theory] and removed [clauses] */
data class Success(
override val theory: Theory,
@JsName("clauses") val clauses: Iterable
) : RetractResult() {
/** Gets the first successfully retracted clause */
@JsName("firstClause")
val firstClause: Clause
get() = clauses.first()
}
/** A failed "retract" operation result, carrying the unchanged [theory] */
data class Failure(override val theory: Theory) : RetractResult()
}