package DX::Resolution;
+use DX::Utils qw(expand_deps);
use DX::Class;
has veracity_depends_on => (is => 'ro', required => 1);
sub remainder { () }
+sub for_deparse {
+ my ($self) = @_;
+ [ statement => [
+ [ symbol => 'resolution' ],
+ [ pairs => [
+ (@{$self->actions}
+ ? [ actions => [ block => $self->actions ] ]
+ : ()),
+ [ veracity_depends_on => [ block => [
+ map [ statement => [
+ [ symbol => (split '::', ${$_->[0]})[-1] ],
+ [ value_path => [ @{$_}[1..$#$_] ] ],
+ ] ], @{expand_deps($self->veracity_depends_on)}
+ ] ] ],
+ ] ],
+ ] ];
+}
+
1;
use DX::Step::Backtrack;
use DX::Step::ResolveProposition;
+use DX::Utils qw(expand_deps);
use DX::Class;
has proposition => (is => 'ro');
sub for_deparse {
my ($self) = @_;
[ statement => [
- [ symbol => 'rspace' ],
- [ block => $self->members ],
+ [ symbol => 'resolution_space' ],
+ [ pairs => [
+ [ proposition => $self->proposition ],
+ [ geometry_depends_on => [ block => [
+ map [ statement => [
+ [ symbol => (split '::', ${$_->[0]})[-1] ],
+ [ value_path => [ @{$_}[1..$#$_] ] ],
+ ] ], @{expand_deps($self->geometry_depends_on)}
+ ] ] ],
+ (@{$self->aperture}
+ ? [ aperture => [ block => [
+ map [ statement => [
+ [ symbol => (split '::', ${$_->[0]})[-1] ],
+ [ value_path => [ @{$_}[1..$#$_] ] ],
+ ] ], @{$self->aperture}
+ ] ] ]
+ : ()),
+ [ members => [ block => [ @{$self->members} ] ] ]
+ ] ],
] ];
}
return $self->but(implementation_candidates => \@rest);
}
+sub for_deparse {
+ my ($self) = @_;
+ [ statement => [
+ [ symbol => 'resolution_strategy' ],
+ [ pairs => [
+ [ action_prototypes => [ block => [
+ map {
+ my ($inv, $type, @args) = @$_;
+ [ statement => [
+ [ symbol => $type ],
+ [ value_path => $inv->value_path ],
+ @args
+ ] ]
+ } @{$self->action_prototypes}
+ ] ] ],
+ [ implementation_candidates => [ block => [
+ map [ block => [
+ map [ block => [
+ map +($_->value_path ? [ value_path => $_->value_path ] : $_), @$_
+ ] ], @$_
+ ] ], @{$self->implementation_candidates}
+ ] ] ]
+ ] ],
+ ] ];
+}
+
1;
package DX::Role::Predicate;
+use Object::Tap;
use DX::Role;
sub resolution_step_for {
my ($self, $prop, @args) = @_;
$self->_resolution_space_for(@args)
->but(proposition => $prop)
+ ->$_tap(sub { trace rspace => $_[0] })
->next_step;
}
trace backtrack => [ statement => [ [ symbol => 'backtrack' ] ] ];
foreach my $adj (@{$ss->decisions_taken}) {
my ($rspace_was, $ss_was) = @$adj;
+ trace rspace => [ statement => [
+ [ symbol => 'remaining' ],
+ @{$rspace_was->remaining_resolution_space->for_deparse->[1]}
+ ] ];
return $ss_was->but(
next_step => $rspace_was->remaining_resolution_space->next_step
);
use DX::Step::Backtrack;
use Types::Standard qw(ArrayRef);
+use DX::Utils qw(expand_deps);
use DX::Class;
has depends_on => (is => 'lazy', init_arg => undef, builder => sub {
my ($self) = @_;
- my $_expand_dep = sub {
- my ($type, @path) = @{$_[0]};
- my @expanded = map {
- ref() ? @{$_->value_path or return ()} : $_
- } @path;
- return [ $type, @expanded ];
- };
- [ map $_expand_dep->($_),
- @{$self->current_resolution->veracity_depends_on} ];
+ expand_deps($self->current_resolution->veracity_depends_on);
});
has alternative_step => (is => 'lazy', init_arg => undef, builder => sub {
(@{$self->actions}
? [ statement => [
[ symbol => 'actions' ],
- [ block => [ @{$self->actions} ] ],
+ [ block => $self->actions ],
] ]
: ()),
[ statement => [
our @EXPORT_OK = (
@const,
(my @builders = qw(rspace rstrat res string number dict proposition)),
- 'deparse', '*trace',
+ 'deparse', '*trace', 'expand_deps',
);
our %EXPORT_TAGS = (
return [ $type, @expanded ];
}
-sub _expand_deps {
+sub expand_deps {
[ map _expand_dep($_), @{$_[0]} ]
}