Halt

sealed interface Halt : Solution

A type representing a failed (halted) solution because of an exception

Properties

Link copied to clipboard
abstract override val exception: ResolutionException

The exception that made resolution halt.

Link copied to clipboard
abstract val isHalt: Boolean

Whether this is a Halt (aborted by an exception) solution

Link copied to clipboard
abstract val isNo: Boolean

Whether this is a No (failed) solution

Link copied to clipboard
abstract val isYes: Boolean

Whether this is a Yes (successful) solution

Link copied to clipboard
abstract val query: Struct

The original goal to which this solution refers

Link copied to clipboard
abstract val solvedQuery: Struct?

The Struct representing the solution, or null in case of a non-successful solution

Link copied to clipboard

The substitution that has been applied to find the solution, or a failed substitution

Link copied to clipboard
abstract val tags: Map<String, Any>

Functions

Link copied to clipboard
open fun <U : Solution> as(): U?
Link copied to clipboard
open override fun asHalt(): Solution.Halt

Casts the current Solution to Halt, if possible, or returns null otherwise

Link copied to clipboard
open fun asNo(): Solution.No?

Casts the current Solution to No, if possible, or returns null otherwise

Link copied to clipboard
open fun asYes(): Solution.Yes?

Casts the current Solution to Yes, if possible, or returns null otherwise

Link copied to clipboard
open fun <U : Solution> castTo(): U
Link copied to clipboard

Casts the current Solution to Halt, if possible

Link copied to clipboard
open fun castToNo(): Solution.No

Casts the current Solution to No, if possible

Link copied to clipboard

Casts the current Solution to Yes, if possible

Link copied to clipboard
abstract override fun cleanUp(): Solution.Halt

Returns a Solution equivalent to this one, but with every variable not occurring in query (nor bound, in substitution, to a variable occurring in query) removed from substitution. Useful to drop resolution-internal variables before presenting a solution to a user.

Link copied to clipboard
open fun containsTag(name: String): Boolean
Link copied to clipboard
abstract fun copy(query: Struct = this.query, exception: ResolutionException = this.exception): Solution.Halt

Returns a Halt solution identical to this one, except for the explicitly-provided arguments.

Link copied to clipboard
open fun <T : Any> getTag(name: String): T?
Link copied to clipboard
abstract override fun replaceTags(tags: Map<String, Any>): Solution.Halt
Link copied to clipboard
abstract fun valueOf(variable: Var): Term?

Returns the Term bound to variable in substitution, or null if variable is unbound (or this is not a Yes solution).

abstract fun valueOf(variable: String): Term?

Same as valueOf, but looking variable up by name rather than by Var instance.

Link copied to clipboard
open fun <T> whenIs(yes: (Solution.Yes) -> T? = null, no: (Solution.No) -> T? = null, halt: (Solution.Halt) -> T? = null, otherwise: (Solution) -> T = { throw IllegalStateException("Cannot handle solution $it") }): T

Exhaustively (or partially) pattern-matches this Solution against its three possible subtypes, invoking whichever of yes/no/halt corresponds to this solution's actual kind, or otherwise if that branch was left null (by default, throwing IllegalStateException).