View Source Guesswork.Answer.Binding (Guesswork v0.4.4)

A 'bound' entity, that is a possible values (notted or exact) and computations, connected to a variable.

Summary

Functions

Applies the env to any computations stored in the binding. If any results disagree, the action fails and nil is returned. Any incomplete computation is ignored.

Takes two bindings and attempts to merge them. Any disagreement between the two will result in failure.

Turns the binding into a simple variable, result pair.

Types

@type t() :: %Guesswork.Answer.Binding{
  computations: [{Guesswork.Answer.Computation.t(), boolean()}],
  value: value(),
  variable_display: String.t()
}
@type value() ::
  {:bound, Guesswork.Ast.Term.entity()}
  | {:not, [Guesswork.Ast.Term.entity()]}
  | :unbound

Functions

Link to this function

add_computation(binding, computation, negated)

View Source
@spec add_computation(t(), Guesswork.Answer.Computation.t(), boolean()) :: t()
Link to this function

apply(binding, env, query_id)

View Source
@spec apply(t(), Guesswork.Ast.Statement.env(), String.t()) :: t() | nil

Applies the env to any computations stored in the binding. If any results disagree, the action fails and nil is returned. Any incomplete computation is ignored.

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

Takes two bindings and attempts to merge them. Any disagreement between the two will result in failure.

Link to this function

new(display, comp, negated)

View Source
@spec to_pair(t()) :: {String.t(), String.t()}

Turns the binding into a simple variable, result pair.