make search state operate on search states a bit more
Matt S Trout [Sun, 19 Jun 2016 19:56:07 +0000 (19:56 +0000)]
lib/DX/SearchState.pm

index d119d9b..b1b4038 100644 (file)
@@ -36,26 +36,24 @@ sub with_one_step {
   my ($self) = @_;
   my $hyp = $self->current_hypothesis;
   return undef unless my $step = $self->next_step;
-  my ($first_alt, @rest_alt) = my @alt = @{$self->alternatives};
   my ($new_ss, $alt_step) = $step->apply_to($self);
-  my $new_hyp = ($new_ss ? $new_ss->current_hypothesis : undef);
-  if ($new_hyp) {
-    return $self->but(
-      current_hypothesis => $new_hyp,
+  if ($new_ss) {
+    return $new_ss->but(
       alternatives => [
         ($alt_step
           ? [ $hyp, $alt_step ]
           : ()),
-        @alt
+        @{$new_ss->alternatives}
       ],
       next_step => DX::Step::InvokeNextPredicate->new(
-        proposition => $self->next_proposition($new_hyp),
+        proposition => $new_ss->next_proposition,
       ),
     );
   }
   if ($alt_step) {
     return $self->but(next_step => $alt_step);
   }
+  my ($first_alt, @rest_alt) = @{$self->alternatives};
   return undef unless $first_alt;
   trace 'search.backtrack.rewind_to' => $first_alt->[1];
   return $self->but(