SideEffect

abstract class SideEffect

A state change to be applied to an ExecutionContext after a it.unibo.tuprolog.solve.primitive.Primitive has run, rather than mutated directly by the primitive itself. Primitives attach zero or more SideEffects to their it.unibo.tuprolog.solve.primitive.Solve.Response (see it.unibo.tuprolog.solve.primitive.Solve.Request.replyWith), and the resolution strategy folds them, in order, over the context via ExecutionContext.apply -- each applyTo call producing a new, immutable ExecutionContext rather than mutating the one it receives.

Every concrete SideEffect subtype nested here covers one specific piece of mutable state a solver carries (clauses in either knowledge base, flags, libraries, operators, I/O channels, custom data), typically in both a "reset to" and "alter by adding/removing" flavour. SideEffectFactory/SideEffectsBuilder are the ergonomic way to construct these without naming each subtype explicitly.

See also

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
abstract class AddClausesToKb(clauses: Iterable<Clause>, val onTop: Boolean) : SideEffect.SetClausesOfKb

Base class for side effects adding clauses to a knowledge base, either at the front (onTop) or the back.

Link copied to clipboard
data class AddDynamicClauses(val clauses: Iterable<Clause>, val onTop: Boolean = false) : SideEffect.AddClausesToKb

Adds clauses to the dynamic knowledge base, at the front if onTop, at the back otherwise.

Link copied to clipboard

Adds every library in libraries to the loaded Runtime.

Link copied to clipboard
data class AddStaticClauses(val clauses: Iterable<Clause>, val onTop: Boolean = false) : SideEffect.AddClausesToKb

Adds clauses to the static knowledge base, at the front if onTop, at the back otherwise.

Link copied to clipboard

Base class for AlterRuntime side effects expressible as a Runtime (a set of aliased Librarys).

Link copied to clipboard
abstract class AlterChannels : SideEffect

Base class for side effects altering the I/O channel stores.

Link copied to clipboard

Base class for AlterChannels side effects addressing channels by names only (e.g. to close them).

Link copied to clipboard
abstract class AlterCustomData(val data: Map<String, Any>, val reset: Boolean = false) : SideEffect

Base class for side effects altering one it.unibo.tuprolog.solve.data.CustomDataStore tier with data, either merging it in, or replacing the tier outright if reset.

Link copied to clipboard
abstract class AlterFlags : SideEffect

Base class for side effects altering the FlagStore.

Link copied to clipboard

Base class for AlterFlags side effects carrying explicit name-value flags entries.

Link copied to clipboard

Base class for AlterFlags side effects addressing flags by names only (e.g. to clear them).

Link copied to clipboard

Base class for AlterChannels side effects carrying named inputChannels to add/set.

Link copied to clipboard

Base class for AlterRuntime side effects addressing libraries by aliases only.

Link copied to clipboard
abstract class AlterLibrary(val library: Library) : SideEffect.AlterAliasedRuntime

Base class for AlterRuntime side effects concerning a single library.

Link copied to clipboard
abstract class AlterOperators(val operators: Iterable<Operator>) : SideEffect

Base class for side effects altering the declared OperatorSet.

Link copied to clipboard

Base class for AlterChannels side effects carrying named outputChannels to add/set.

Link copied to clipboard
abstract class AlterRuntime : SideEffect

Base class for side effects altering the loaded Runtime of libraries.

Link copied to clipboard

Removes the flags named in names from the FlagStore.

Link copied to clipboard

Closes/removes the input channels named in names.

Link copied to clipboard

Closes/removes the output channels named in names.

Link copied to clipboard
data class LoadLibrary(val library: Library) : SideEffect.AlterLibrary

Adds library to the loaded Runtime.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Base class for side effects removing clauses from a knowledge base.

Link copied to clipboard

Removes clauses from the dynamic knowledge base.

Link copied to clipboard

Removes operators from the current OperatorSet.

Link copied to clipboard

Removes clauses from the static knowledge base.

Link copied to clipboard

Replaces the dynamic knowledge base with a MutableTheory built out of clauses.

Link copied to clipboard

Replaces the whole FlagStore with one built out of flags.

Link copied to clipboard

Replaces the whole input channel store with inputChannels.

Link copied to clipboard

Nominally replaces the whole OperatorSet with operators.

Link copied to clipboard

Replaces the whole output channel store with outputChannels.

Link copied to clipboard

Replaces the whole loaded Runtime with libraries.

Link copied to clipboard

Replaces the static knowledge base with a Theory built out of clauses.

Link copied to clipboard
abstract class SetClausesOfKb(val clauses: Iterable<Clause>) : SideEffect

Base class for side effects computing a Theory (or MutableTheory) out of clauses, for either knowledge base.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Merges flags into the current FlagStore, overriding any existing entry with the same name.

Link copied to clipboard

Merges operators into the current OperatorSet.

Link copied to clipboard
Link copied to clipboard

Removes the libraries named in aliases from the loaded Runtime.

Link copied to clipboard
data class UpdateLibrary(val library: Library) : SideEffect.AlterLibrary

Replaces, within the loaded Runtime, the library sharing library's alias with library itself.

Functions

Link copied to clipboard
abstract fun applyTo(context: ExecutionContext): ExecutionContext

Produces the ExecutionContext resulting from applying this side effect to context.