1 package DX::Step::ResolveProposition;
3 use DX::Step::EnterRecheck;
5 use Types::Standard qw(ArrayRef);
6 use DX::Utils qw(deparse);
10 with 'DX::Role::Step';
12 has actions => (is => 'ro', isa => ArrayRef[Action], required => 1);
14 has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1);
16 has resolves => (is => 'ro', isa => Proposition);
18 has alternative_step => (is => 'ro', isa => Step);
21 my ($self, @actions) = @_;
22 $self->but(actions => [ @actions, @{$self->actions} ]);
25 sub but_with_dependencies_on {
26 my ($self, @deps) = @_;
27 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
32 trace 'step.apply.old_hyp '.$self => $ss->current_hypothesis;
33 trace 'step.apply.actions '.$self => $self->actions;
34 my $new_ss = $self->_apply_to_ss($ss);
35 return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
36 trace 'step.apply.new_hyp '.$self => $new_ss->current_hypothesis;
38 if (my $prop = $new_ss->next_proposition) {
39 DX::Step::ConsiderProposition->new(
43 $new_ss->on_solution_step
46 my $alt_step = $self->alternative_step;
52 [ $ss->current_hypothesis, $alt_step ],
62 my ($self, $old_ss) = @_;
63 my $old_hyp = $old_ss->current_hypothesis;
64 (my $hyp, my @recheck) = $old_hyp->with_resolution(
65 $self->resolves, $self->depends_on, $self->actions
67 return undef unless $hyp;
68 return $self->_recheck_for(
69 $old_ss->but(current_hypothesis => $hyp),
75 my ($self, $old_ss, @recheck) = @_;
76 return $old_ss unless @recheck;
78 foreach my $prop (@recheck) {
79 return undef unless $ss = $self->_recheck_one($ss, $prop);
85 my ($self, $old_ss, $prop) = @_;
87 my $ss = $old_ss->but(
88 next_step => DX::Step::EnterRecheck->new(
89 proposition_list => [ $prop ],
90 on_completion_step => DX::Step::MarkAsSolution->new,
94 my $sp = DX::SearchProcess->new(
95 current_search_state => $ss,
98 my $sol_sp = $sp->find_solution;
101 trace 'step.recheck.fail' => 'argh';
105 return $sol_sp->current_search_state->but(is_solution_state => 0);