steps now operate on search states
Matt S Trout [Sun, 19 Jun 2016 17:52:44 +0000 (17:52 +0000)]
lib/DX/SearchState.pm
lib/DX/Step/InvokeNextPredicate.pm
lib/DX/Step/Normal.pm

index d29dc09..d119d9b 100644 (file)
@@ -37,7 +37,8 @@ sub with_one_step {
   my $hyp = $self->current_hypothesis;
   return undef unless my $step = $self->next_step;
   my ($first_alt, @rest_alt) = my @alt = @{$self->alternatives};
-  my ($new_hyp, $alt_step) = $step->apply_to($hyp);
+  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,
index 510d013..3e969e9 100644 (file)
@@ -7,7 +7,8 @@ with 'DX::Role::Step';
 has proposition => (is => 'ro', required => 1);
 
 sub apply_to {
-  my ($self, $hyp) = @_;
+  my ($self, $ss) = @_;
+  my $hyp = $ss->current_hypothesis;
   return (undef, $self->proposition->resolve_for($hyp->scope));
 }
 
index d5bb1e3..350d4dc 100644 (file)
@@ -25,13 +25,14 @@ sub but_with_dependencies_on {
 }
 
 sub apply_to {
-  my ($self, $old_hyp) = @_;
+  my ($self, $ss) = @_;
+  my $old_hyp = $ss->current_hypothesis;
   trace 'step.apply.old_hyp '.$self => $old_hyp;
   trace 'step.apply.actions '.$self => $self->actions;
   my $new_hyp = $self->_apply_to_hyp($old_hyp);
   return (undef, $self->alternative_step) unless $new_hyp;
   trace 'step.apply.new_hyp '.$self => $new_hyp;
-  return ($new_hyp, $self->alternative_step);
+  return ($ss->but(current_hypothesis => $new_hyp), $self->alternative_step);
 }
 
 sub _apply_to_hyp {