View Source Guesswork.Answer.PartiallyEvaluated (Guesswork v0.6.0)

Represents a partially evaluated enumerable of answers, allowing the answer sets to be handled one at a time.

Summary

Functions

Checks if the stream has been fully consumed

If possible, takes the first item in the stream and evaluates it. Otherwise marks the value as done.

Takes a list of partial evaluations and attempts to calculate the next set of unioned answer sets, based on the next evaluated answer set unioned with the previously evaluated answer sets.

Types

@type t() :: %Guesswork.Answer.PartiallyEvaluated{
  done?: boolean(),
  evaluated: [Guesswork.Answer.t()],
  evaluated_count: integer(),
  stream: Enumerable.t(Guesswork.Answer.t())
}

Functions

Link to this function

done?(partially_evaluated)

View Source
@spec done?(t()) :: boolean()

Checks if the stream has been fully consumed

Link to this function

evaluated_count(partially_evaluated)

View Source
@spec evaluated_count(t()) :: integer()
@spec head(t()) :: t()

If possible, takes the first item in the stream and evaluates it. Otherwise marks the value as done.

@spec new(Enumerable.t(Guesswork.Answer.t())) :: t()
@spec next_unions([t()]) ::
  :empty | :done | {:ok, [t()], [Guesswork.Answer.t() | :halt]}

Takes a list of partial evaluations and attempts to calculate the next set of unioned answer sets, based on the next evaluated answer set unioned with the previously evaluated answer sets.

The returned unions can either result in an answer set, or a :halt, which indicates that a stop condition has been met and that stream should stop.