View Source Guesswork.Answer (Guesswork v0.4.4)

Answers are maps of variable id to bindings as well as any tests that must be checked.

Summary

Functions

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.

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

@spec flatten(t()) :: %{required(String.t()) => String.t()}

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 new(String.t() | nil) :: t()
Link to this function

put_binding(answer, variable, value, negated)

View Source
@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()
@spec resolve(t()) :: t() | nil

Resolves both tests and computations.

Link to this function

resolve_computations(answer)

View Source
@spec resolve_computations(t()) :: 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_tests(t()) :: t() | nil

Checks that all tests pass, ignoring any incomplete computation. If the computable tests do not pass, nil is returned.

@spec union(t(), t()) :: t() | nil

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.