View Source Guesswork.Constraint protocol (Guesswork v0.8.0)
Represents a relationship between values that can be evaluated to produce or test new values.
Summary
Types
A simple value that indicates the result of a constraint.
All the types that implement this protocol.
Functions
Applies the known values to the constraint, attempting to build a new value.
Displays the constraint in a human readable way.
Opaque values should return nil
.
Pulls all possible sets of inputs that could resolve the constraint.
Types
@type result() :: :noanswer | :error | :ok | Guesswork.Constraint.Result.t()
A simple value that indicates the result of a constraint.
:error
if the constraint is invalid.:noanswer
if the constraint cannot be resolved.:ok
if the constraint resolves to true.%Guesswork.Constraint.Result{}
if a new value has been derived. The last term indicates if the term should be negated.
@type t() :: term()
All the types that implement this protocol.
Functions
@spec apply(t(), Guesswork.Ast.Statement.env()) :: result()
Applies the known values to the constraint, attempting to build a new value.
Displays the constraint in a human readable way.
Opaque values should return nil
.
@spec inputs(t()) :: [[Guesswork.Ast.Variable.t(), ...], ...]
Pulls all possible sets of inputs that could resolve the constraint.