View Source Guesswork.Answer (Guesswork v0.6.0)
Answers are maps of variable id to bindings as well as any tests that must be checked.
Summary
Functions
Takes an answer set and removes any binding not passed to the function.
Extracts the displayable information from the answer set, returning a simple map.
Pulls all bound, concrete values from the answer set.
Resolves both tests and computations as well as checking if the stop conditions have been met and the answer stream should halt.
Attempts to use any bound values stored in the answer set to resolve stored computations. Any disagreement found in the new bindings returns a nil.
Checks if the answer set indicates that a stop condition has been met.
If a stop condition is met, :halt
is returned.
Checks that all tests pass, ignoring any incomplete computation. If the computable tests do not pass, nil is returned.
Replaces all bound variables using the variable id to variable map.
Takes two answer sets and attempts to take the union of them. If any variables point to contradicting values the process will fail and return nil.
Types
@type bindings() :: %{required(String.t()) => Guesswork.Answer.Binding.t()}
@type t() :: %Guesswork.Answer{ bindings: bindings(), query_id: String.t() | nil, stop_conditions: [Guesswork.Answer.Computation.t()], tests: [Guesswork.Answer.Test.t()] }
Functions
Takes an answer set and removes any binding not passed to the function.
:halt
s are passed through to facilitate stop conditions.
@spec flatten(t()) :: %{required(String.t()) => Guesswork.Answer.Binding.value()}
Extracts the displayable information from the answer set, returning a simple map.
@spec get_env(t()) :: Guesswork.Ast.Statement.env()
Pulls all bound, concrete values from the answer set.
@spec put_binding( t(), Guesswork.Ast.Variable.t(), Guesswork.Ast.Term.entity() | Guesswork.Answer.Computation.t(), boolean() ) :: {:ok, t()} | :error
@spec put_stop_condition(t(), Guesswork.Answer.Computation.t()) :: t()
@spec put_test(t(), Guesswork.Answer.Test.t()) :: t()
Resolves both tests and computations as well as checking if the stop conditions have been met and the answer stream should halt.
:halt
s are passed through to facilitate stop conditions.
@spec resolve_computations(t(), nil | Guesswork.Ast.Statement.env()) :: t() | nil
Attempts to use any bound values stored in the answer set to resolve stored computations. Any disagreement found in the new bindings returns a nil.
@spec resolve_stop_conditions(t()) :: {t(), Guesswork.Ast.Statement.env()} | :halt
Checks if the answer set indicates that a stop condition has been met.
If a stop condition is met, :halt
is returned.
@spec resolve_tests(t(), Guesswork.Ast.Statement.env()) :: t() | nil
Checks that all tests pass, ignoring any incomplete computation. If the computable tests do not pass, nil is returned.
@spec substitue_variables(t() | :halt, %{ required(String.t()) => Guesswork.Ast.Variable.t() }) :: t() | :halt
Replaces all bound variables using the variable id to variable map.
:halt
s are passed through to facilitate stop conditions.
Takes two answer sets and attempts to take the union of them. If any variables point to contradicting values the process will fail and return nil.
:halt
s are passed through to facilitate stop conditions.