1 package DX::SearchState;
3 use Types::Standard qw(Maybe);
4 use DX::Step::Backtrack;
5 use DX::Step::InvokeNextPredicate;
8 has current_hypothesis => (is => 'ro', isa => Hypothesis, required => 1);
10 has next_step => (is => 'ro', isa => Maybe[Step]);
12 has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
14 has alternatives => (is => 'ro', isa => AlternativeList, required => 1);
16 sub next_proposition {
17 my ($self, $hyp) = @_;
18 $hyp ||= $self->current_hypothesis;
19 $self->propositions->members->[
20 $hyp->resolved_propositions->resolved_count
25 my ($class, $hyp, $props) = @_;
27 current_hypothesis => $hyp,
29 next_step => DX::Step::InvokeNextPredicate->new(
30 proposition => $props->members->[0],
32 propositions => $props,
38 return undef unless my $step = $self->next_step;
39 return $step->apply_to($self);
44 my ($first_alt, @rest_alt) = @{$self->alternatives};
45 return undef unless $first_alt;
46 trace 'search.backtrack.forced' => $first_alt->[0];
48 next_step => DX::Step::Backtrack->new,