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 => DependencyGroupList, required => 1);
17 has depends_on => (is => 'ro', required => 1, coerce => sub {
18 my ($dep_groups) = @_;
20 assert_DependencyGroupList $dep_groups;
22 my ($on, @deps) = @$_;
24 DEP: foreach my $dep (@deps) {
25 my ($type, @path) = @$dep;
28 map { ref() ? @{$_->value_path or next DEP} : $_ } @path
31 (@exp ? [ $on, @exp ] : ());
35 has resolves => (is => 'ro', isa => Proposition);
37 has alternative_step => (is => 'ro', isa => Step);
40 my ($self, @actions) = @_;
41 $self->but(actions => [ @actions, @{$self->actions} ]);
44 sub but_with_dependencies_on {
45 my ($self, @deps) = @_;
46 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
50 my ($self, $old_ss) = @_;
52 if (my $prop = $old_ss->next_proposition) {
53 DX::Step::ConsiderProposition->new(
57 $old_ss->on_solution_step
60 my $alt_step = $self->alternative_step;
61 my $ss = $old_ss->but(
65 [ $old_ss->current_hypothesis, $alt_step ],
66 @{$old_ss->alternatives}
71 my $new_ss = $self->_apply_to_ss($ss);
72 return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
77 my ($self, $old_ss) = @_;
78 my $old_hyp = $old_ss->current_hypothesis;
79 (my $hyp, my @recheck) = $old_hyp->with_resolution(
80 $self->resolves, $self->depends_on, $self->actions
82 return undef unless $hyp;
83 return $self->_recheck_for(
84 $old_ss->but(current_hypothesis => $hyp),
90 my ($self, $old_ss, @recheck) = @_;
92 return $old_ss unless @recheck;
94 my $ss = $old_ss->but(
95 next_step => DX::Step::EnterRecheck->new(
96 proposition_list => \@recheck,
97 on_completion_step => $old_ss->next_step,
98 on_failure_step => DX::Step::Backtrack->new,