follow alternative rspace entries without backtracking, explicitly resolve
[scpubgit/DX.git] / lib / DX / Step / Backtrack.pm
1 package DX::Step::Backtrack;
2
3 use DX::Class;
4
5 with 'DX::Role::Step';
6
7 #has resolution_space => (is => 'ro', isa => ResolutionSpace, required => 1);
8
9 sub apply_to {
10   my ($self, $ss) = @_;
11   trace backtrack => [ statement => [ [ symbol => 'backtrack' ] ] ];
12   foreach my $adj (@{$ss->decisions_taken}) {
13     my ($rspace_was, $ss_was) = @$adj;
14     trace rspace => [ statement => [
15       [ symbol => 'remaining' ],
16       @{$rspace_was->remaining_resolution_space->for_deparse->[1]}
17     ] ];
18     return $ss_was->but(
19       next_step => $rspace_was->remaining_resolution_space->next_step
20     );
21   }
22   return $ss->but(next_step => $ss->on_exhaustion_step);
23 }
24
25 1;