move backtrack step creation into rspace
Matt S Trout [Fri, 30 Mar 2018 16:43:58 +0000 (16:43 +0000)]
lib/DX/ResolutionSpace.pm
lib/DX/Step/ConsiderProposition.pm

index 4210b02..c2bfff6 100644 (file)
@@ -1,6 +1,7 @@
 package DX::ResolutionSpace;
 
 use DX::Utils qw(step);
+use DX::Step::Backtrack;
 use DX::Class;
 
 has proposition => (is => 'ro');
@@ -23,7 +24,7 @@ sub remaining_resolution_space {
 
 sub next_step {
   my ($self) = @_;
-  return undef unless @{$self->members};
+  return DX::Step::Backtrack->new unless @{$self->members};
   return step(
     resolves => $self->proposition,
     resolution_space => $self,
index 0b60a82..485d14b 100644 (file)
@@ -15,10 +15,7 @@ sub apply_to {
       @{$self->proposition->for_deparse->[1]},
     ],
   ];
-  if (my $step = $self->proposition->resolve_for($hyp->scope)) {
-    return $ss->but(next_step => $step);
-  }
-  return $ss->but(next_step => DX::Step::Backtrack->new);
+  return $ss->but(next_step => $self->proposition->resolve_for($hyp->scope));
 }
 
 1;