1 package DX::Step::ResolveProposition;
3 use DX::Step::EnterRecheck;
4 use DX::Step::Backtrack;
6 use Types::Standard qw(ArrayRef);
7 use DX::Utils qw(deparse);
11 with 'DX::Role::Step';
13 has actions => (is => 'ro', isa => ArrayRef[Action], required => 1);
15 has depends_on => (is => 'ro', isa => ArrayRef[DependencySpec], required => 1);
17 has resolves => (is => 'ro', isa => Proposition);
19 has alternative_step => (is => 'ro', isa => Step);
22 my ($self, @actions) = @_;
23 $self->but(actions => [ @actions, @{$self->actions} ]);
26 sub but_with_dependencies_on {
27 my ($self, @deps) = @_;
28 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
32 my ($self, $old_ss) = @_;
34 if (my $prop = $old_ss->next_proposition) {
35 DX::Step::ConsiderProposition->new(
39 $old_ss->on_solution_step
42 my $alt_step = $self->alternative_step;
43 my $ss = $old_ss->but(
46 ? (adjustments_made => [
48 @{$old_ss->adjustments_made}
53 my $new_ss = $self->_apply_to_ss($ss);
54 return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
59 my ($self, $old_ss) = @_;
60 my $old_hyp = $old_ss->current_hypothesis;
61 (my $hyp, my @recheck) = $old_hyp->with_resolution(
62 $self->resolves, $self->depends_on, $self->actions
64 return undef unless $hyp;
65 return $self->_recheck_for(
66 $old_ss->but(current_hypothesis => $hyp),
72 my ($self, $old_ss, @recheck) = @_;
74 return $old_ss unless @recheck;
76 my $ss = $old_ss->but(
77 next_step => DX::Step::EnterRecheck->new(
78 proposition_list => \@recheck,
79 on_completion_step => $old_ss->next_step,
80 on_failure_step => DX::Step::Backtrack->new,