View Source Guesswork.Answer (Guesswork v0.5.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.
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 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(), tests: [Guesswork.Answer.Test.t()] }
Functions
Takes an answer set and removes any binding not passed to the function.
@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_test(t(), Guesswork.Answer.Test.t()) :: t()
Resolves both tests and computations.
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 that all tests pass, ignoring any incomplete computation. If the computable tests do not pass, nil is returned.
@spec substitue_variables(t(), %{required(String.t()) => Guesswork.Ast.Variable.t()}) :: t()
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.