cleanup resolveprop apply_to logic a bit
Matt S Trout [Fri, 15 Jul 2016 20:54:51 +0000 (20:54 +0000)]
lib/DX/Step/ResolveProposition.pm

index d92ac24..66a980d 100644 (file)
@@ -26,29 +26,29 @@ sub but_with_dependencies_on {
 
 sub apply_to {
   my ($self, $ss) = @_;
-  my $old_hyp = $ss->current_hypothesis;
-  trace 'step.apply.old_hyp '.$self => $old_hyp;
+  trace 'step.apply.old_hyp '.$self => $ss->current_hypothesis;
   trace 'step.apply.actions '.$self => $self->actions;
   my $new_ss = $self->_apply_to_ss($ss);
   return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
-  my $new_hyp = $new_ss->current_hypothesis;
-  trace 'step.apply.new_hyp '.$self => $new_hyp;
+  trace 'step.apply.new_hyp '.$self => $new_ss->current_hypothesis;
   my $ns = do {
-    if (my $prop = $ss->next_proposition($new_hyp)) {
+    if (my $prop = $new_ss->next_proposition) {
       DX::Step::ConsiderProposition->new(
         proposition => $prop
       )
     } else {
-      $ss->on_solution_step
+      $new_ss->on_solution_step
     }
   };
   my $alt_step = $self->alternative_step;
   return (
-    $ss->but(
-      current_hypothesis => $new_hyp,
+    $new_ss->but(
       next_step => $ns,
       ($alt_step
-        ? (alternatives => [ [ $old_hyp, $alt_step ], @{$ss->alternatives} ])
+        ? (alternatives => [
+            [ $ss->current_hypothesis, $alt_step ],
+            @{$ss->alternatives}
+          ])
         : ()
       ),
     ),