From: Matt S Trout <mst@shadowcat.co.uk>
Date: Sat, 2 Apr 2016 21:50:53 +0000 (+0000)
Subject: cut over to next_proposition using resolved_count
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f25e6894d06995a4d10da0f59b96447816b67a01;p=scpubgit%2FDX.git

cut over to next_proposition using resolved_count
---

diff --git a/lib/DX/Hypothesis.pm b/lib/DX/Hypothesis.pm
index e8b66c0..95c05f3 100644
--- a/lib/DX/Hypothesis.pm
+++ b/lib/DX/Hypothesis.pm
@@ -25,8 +25,6 @@ has action_applications => (
 
 has action_policy => (is => 'ro', isa => ActionPolicy, required => 1);
 
-sub head_proposition { shift->outstanding_propositions->[0] }
-
 sub with_actions {
   my ($self, @actions) = @_;
   my $hyp = $self;
diff --git a/lib/DX/ResolvedPropositionSet.pm b/lib/DX/ResolvedPropositionSet.pm
index 73d6c63..357186b 100644
--- a/lib/DX/ResolvedPropositionSet.pm
+++ b/lib/DX/ResolvedPropositionSet.pm
@@ -11,6 +11,8 @@ has propositions => (is => 'ro', isa => ArrayRef[Proposition], required => 1);
 
 has scope_depth => (is => 'ro', required => 1);
 
+sub resolved_count { scalar @{$_[0]->propositions} }
+
 sub new_empty {
   my ($class) = @_;
   $class->new(
diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm
index def236d..9c831df 100644
--- a/lib/DX/SearchState.pm
+++ b/lib/DX/SearchState.pm
@@ -12,7 +12,12 @@ has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
 
 has alternatives => (is => 'ro', isa => AlternativeList, required => 1);
 
-sub next_proposition { $_[0]->current_hypothesis->head_proposition }
+sub next_proposition {
+  my ($self) = @_;
+  $self->propositions->members->[
+    $self->current_hypothesis->resolved_propositions->resolved_count
+  ];
+}
 
 sub new_for {
   my ($class, $hyp, $props) = @_;
@@ -20,7 +25,7 @@ sub new_for {
     current_hypothesis => $hyp,
     alternatives => [],
     next_step => DX::Step::InvokeNextPredicate->new(
-      proposition => $hyp->head_proposition,
+      proposition => $props->members->[0],
     ),
     propositions => $props,
   );
@@ -60,7 +65,7 @@ sub with_one_step {
 
 sub find_solution {
   my $state = $_[0];
-  while ($state and @{$state->current_hypothesis->outstanding_propositions}) {
+  while ($state and $state->next_proposition) {
     $state = $state->with_one_step;
   }
   trace 'search.solution.hyp' => $state->current_hypothesis if $state;