with 'DX::Role::Predicate';
-sub _possible_resolution_list {
- my ($self, @args) = @_;
- my $rspace = $self->_resolution_space_for(@args);
- return () unless my @members = @{$rspace->members};
- return map step(
- actions => $_->actions,
- depends_on => $_->veracity_depends_on
- ), @members;
-}
-
sub _resolution_space_for {
my ($self, $left, $right) = @_;
with 'DX::Role::Predicate';
-sub _possible_resolution_list {
- my ($self, @args) = @_;
- my $rspace = $self->_resolution_space_for(@args);
- return () unless my @members = @{$rspace->members};
- return map {
- $_->isa('DX::Resolution')
- ? step(
- actions => $_->actions,
- depends_on => $_->veracity_depends_on,
- )
- : do {
- my ($db, @ap) = (
- $_->veracity_depends_on_builder, @{$_->action_prototypes}
- );
- map {
- my @cand = @{$_};
- step(
- actions => [
- map {
- my ($inv, $type, @args) = @{$ap[$_]};
- $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
- } 0..$#ap
- ],
- depends_on => $db->(@cand),
- )
- } @{$_->implementation_candidates};
- }
- } @members;
-}
-
# member_at Dict Key Value
#
# Dict must be set to a dict (later maybe also an array and Key -> Index)
has actions => (is => 'ro', required => 1);
+sub next_resolution { $_[0] }
+
+sub remainder { () }
+
1;
has members => (is => 'ro', required => 1);
+sub next_resolution {
+ my ($self) = @_;
+ return undef unless my ($first) = @{$self->members};
+ return $first->next_resolution;
+}
+
+sub remaining_resolution_space {
+ my ($self) = @_;
+ die "Sense makes not" unless my ($first, @rest) = @{$self->members};
+ return $self->but(members => [ $first->remainder, @rest ]);
+}
+
1;
package DX::ResolutionStrategy;
+use DX::Resolution;
use DX::Class;
has action_prototypes => (is => 'ro', required => 1);
];
});
+sub next_resolution {
+ my ($self) = @_;
+ return undef unless my ($first) = @{$self->implementation_candidates};
+ my @ap = @{$self->action_prototypes};
+ my @cand = @$first;
+ return DX::Resolution->new(
+ actions => [
+ map {
+ my ($inv, $type, @args) = @{$ap[$_]};
+ $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
+ } 0..$#ap
+ ],
+ veracity_depends_on => $self->veracity_depends_on_builder->(@cand),
+ );
+}
+
+sub remainder {
+ my ($self) = @_;
+ my ($first, @rest) = @{$self->implementation_candidates};
+ return () unless @rest;
+ return $self->but(implementation_candidates => \@rest);
+}
+
1;
use DX::Utils qw(step CONTENTS_OF);
use DX::Role;
+sub _possible_resolution_list {
+ my ($self, @args) = @_;
+ my $rspace = $self->_resolution_space_for(@args);
+ my @res;
+ while (my $next_res = $rspace->next_resolution) {
+ $rspace = $rspace->remaining_resolution_space;
+ push @res, step(
+ actions => $next_res->actions,
+ depends_on => $next_res->veracity_depends_on,
+ );
+ }
+ return @res;
+}
+
sub resolution_step_for {
my ($self, $prop, @args) = @_;
my ($last, @rest) = reverse $self->_possible_resolution_list(@args);