package DX::Predicate::Dict;
-use DX::Utils qw(rspace res dict TYPE_OF);
+use DX::Utils qw(rspace res dict TYPE_OF expand_deps);
use DX::Class;
with 'DX::Role::Predicate';
die "dict called with non-dict prototype"
if $proto and not $proto->isa('DX::Value::Dict');
- my $deps = [ [ TYPE_OF ,=> $arg ] ];
+ my $deps = expand_deps([ [ TYPE_OF ,=> $arg ] ]);
my $actions =
$arg->is_set ? [] : [ $arg->action_for_set_value($proto||dict()) ];
package DX::Predicate::Eq;
-use DX::Utils qw(rspace res CONTENTS_OF);
+use DX::Utils qw(rspace res CONTENTS_OF expand_deps);
use DX::Class;
with 'DX::Role::Predicate';
sub _resolution_space_for {
my ($self, $left, $right) = @_;
- my $deps = [ [ CONTENTS_OF ,=> $left ], [ CONTENTS_OF ,=> $right ] ];
+ my $deps = expand_deps([
+ [ CONTENTS_OF ,=> $left ], [ CONTENTS_OF ,=> $right ]
+ ]);
my $aperture = [ map @{$_->aperture_for_set_value}, $left, $right ];
package DX::Predicate::MemberAt;
-use DX::Utils qw(:builders :dep_types);
+use DX::Utils qw(:builders :dep_types expand_deps);
use DX::ActionBuilder::ProxySetToAdd;
use DX::ActionBuilder::Null;
use DX::Class;
if (my $cur_val = $dict->get_member_at($key)) {
- my $deps = [
+ my $deps = expand_deps([
[ CONTENTS_OF ,=> $dict, $key->string_value ],
[ CONTENTS_OF ,=> $value ],
- ];
+ ]);
if ($value->is_set) {
}
return rspace(
- geometry_depends_on => [
+ geometry_depends_on => expand_deps([
[ CONTENTS_OF ,=> $dict, $key->string_value ],
[ TYPE_OF ,=> $value ],
- ],
+ ]),
aperture => $value->aperture_for_set_value,
members => [
res(
if ($dict->can_add_member) {
- my $deps = [
+ my $deps = expand_deps([
[ EXISTENCE_OF ,=> $dict, $key->string_value ],
[ TYPE_OF ,=> $value ],
- ];
+ ]);
if ($value->is_set) {
# Dict doesn't allow adding keys and key doesn't exist, so
# the contents of the value is completely irrelevant to the failure
return rspace(
- geometry_depends_on => [
+ geometry_depends_on => expand_deps([
[ EXISTENCE_OF ,=> $dict, $key->string_value ],
- ],
+ ]),
aperture => [],
members => [],
);
], map string($_), $dict->index_list;
return rspace(
- geometry_depends_on => [
+ geometry_depends_on => expand_deps([
[ INDICES_OF ,=> $dict ],
[ TYPE_OF ,=> $key ],
[ TYPE_OF ,=> $value ],
- ],
+ ]),
aperture => [ map @{$_->aperture_for_set_value}, $key, $value ],
members => [
rstrat(
],
veracity_depends_on_builder => sub {
my ($this_key, $this_val) = map @$_, @_;
- return [
+ return expand_deps([
[ CONTENTS_OF ,=> $dict, $this_key->string_value ],
[ CONTENTS_OF ,=> $key ],
[ CONTENTS_OF ,=> $value ],
- ];
+ ]);
},
implementation_candidates => \@cand,
),
with 'DX::Role::Step';
-has resolves => (is => 'lazy', init_arg => undef, builder => sub {
- my ($self) = @_;
- $self->resolution_space->proposition;
-});
-
has resolution_space => (is => 'ro', isa => ResolutionSpace);
-has current_resolution => (is => 'lazy', init_arg => undef, builder => sub {
- my ($self) = @_;
- $self->resolution_space->next_resolution;
-});
-
-has actions => (is => 'lazy', init_arg => undef, builder => sub {
- my ($self) = @_;
- $self->current_resolution->actions;
-});
-
-has depends_on => (is => 'lazy', init_arg => undef, builder => sub {
- my ($self) = @_;
- expand_deps($self->current_resolution->veracity_depends_on);
-});
-
-has alternative_step => (is => 'lazy', init_arg => undef, builder => sub {
- my ($self) = @_;
- my $rspace = $self->resolution_space->remaining_resolution_space;
- return undef unless @{$rspace->members};
- return $rspace->next_step;
-});
+sub resolves { shift->resolution_space->proposition }
+
+sub current_resolution { shift->resolution_space->next_resolution }
+
+sub actions { shift->current_resolution->actions }
+
+sub depends_on { shift->current_resolution->veracity_depends_on }
sub but_first {
my ($self, @actions) = @_;