View Source Guesswork.Answer.PartiallyEvaluated (Guesswork v0.8.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

t()

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

unions_result()

@type unions_result() :: :empty | :done | {:ok, [t()], [Guesswork.Answer.t() | :halt]}

Functions

count_unions(arg1)

@spec count_unions(unions_result()) :: non_neg_integer()

done?(partially_evaluated)

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

Checks if the stream has been fully consumed

evaluated_count(partially_evaluated)

@spec evaluated_count(t()) :: integer()

head(estream)

@spec head(t()) :: t()

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

new(stream)

@spec new(Enumerable.t(Guesswork.Answer.t())) :: t()

next_unions(streams)

@spec next_unions([t()]) :: unions_result()

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.