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

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

Summary

Functions

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

Types

t()

@type t() :: %Guesswork.Answer.Binding{value: value()}

value()

@type value() ::
  {:bound, Guesswork.Ast.Entity.t()} | {:not, [Guesswork.Ast.Entity.t()]}

Functions

get_result_value(binding)

@spec get_result_value(t()) :: Guesswork.Answer.Result.value()

merge(b1, b2)

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

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

Examples

iex> four = Guesswork.Answer.Binding.new(4, false)
...> Guesswork.Answer.Binding.merge(four, four)
four
iex> five = Guesswork.Answer.Binding.new(5, false)
...> Guesswork.Answer.Binding.merge(four, five)
nil
iex> not_five = Guesswork.Answer.Binding.new(5, true)
...> Guesswork.Answer.Binding.merge(four, not_five)
four
iex> not_four = Guesswork.Answer.Binding.new(4, true)
...> Guesswork.Answer.Binding.merge(not_four, not_five)
%Guesswork.Answer.Binding{value: {:not, [4, 5]}}

new(value, bool)

@spec new(Guesswork.Ast.Entity.t(), boolean()) :: t()