]> Witch of Git - mukan/commit
Allow goals to yield to other goals while working
authorCassie Jones <code@witchoflight.com>
Mon, 17 Feb 2020 14:23:35 +0000 (15:23 +0100)
committerCassie Jones <code@witchoflight.com>
Mon, 17 Feb 2020 14:23:35 +0000 (15:23 +0100)
commit014dcfee7bca01cc4cbb5ca7113dc634bc3ac6ea
treef26c23ba9d152814a23b52a58e890587dbd0de27
parentb96aea44193617158428d3e4c8dc04bbee7cae1f
Allow goals to yield to other goals while working

Previously we searched over streams of states, that provided solutions
to the searched sub-goals. This meant though, that if you attempted to
search in a goal which couldn't make progress like the "unproductive"
rule below, it would block forever with no way to yield back to the rest
of the search without producing a wrong result.

  unproductive(X) :- unproductive(X).

The new search works via iterators over Step instead of over State,
where a Step::Working represents a goal which was unable to produce a
result, and instead decided to yield, and a Step::Soln(State) is a
solution like before.

Currently the only goal which will introduce new Working states into the
stream is the delay constructor, before forcing, since recursive goals
are the only non-terminating goals that are in the core.
README.md
src/bin/readme_examples.rs
src/lib.rs
src/main.rs