Yes

sealed interface Yes : Solution

A type representing the successful solution

Properties

Link copied to clipboard

The exception that made resolution halt, if this is a Halt solution, or null otherwise

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 override val solvedQuery: Struct

The query, with substitution applied to it.

Link copied to clipboard
abstract override val substitution: Substitution.Unifier

The Substitution.Unifier that made query succeed.

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 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 override 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.Yes

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, substitution: Substitution.Unifier = this.substitution): Solution.Yes

Returns a Yes 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.Yes
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).