From: Matt S Trout Date: Fri, 30 Mar 2018 18:29:55 +0000 (+0000) Subject: switchover to rspace next_step and dump step() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=29daa5541fda849f06b7bf5ecd2d4a72f263b184;p=scpubgit%2FDX.git switchover to rspace next_step and dump step() --- diff --git a/lib/DX/Predicate/Eq.pm b/lib/DX/Predicate/Eq.pm index a7ca607..e21be8c 100644 --- a/lib/DX/Predicate/Eq.pm +++ b/lib/DX/Predicate/Eq.pm @@ -1,6 +1,6 @@ package DX::Predicate::Eq; -use DX::Utils qw(step rspace res CONTENTS_OF); +use DX::Utils qw(rspace res CONTENTS_OF); use DX::Class; with 'DX::Role::Predicate'; diff --git a/lib/DX/ResolutionSpace.pm b/lib/DX/ResolutionSpace.pm index c2bfff6..817595f 100644 --- a/lib/DX/ResolutionSpace.pm +++ b/lib/DX/ResolutionSpace.pm @@ -1,7 +1,7 @@ package DX::ResolutionSpace; -use DX::Utils qw(step); use DX::Step::Backtrack; +use DX::Step::ResolveProposition; use DX::Class; has proposition => (is => 'ro'); @@ -25,10 +25,7 @@ sub remaining_resolution_space { sub next_step { my ($self) = @_; return DX::Step::Backtrack->new unless @{$self->members}; - return step( - resolves => $self->proposition, - resolution_space => $self, - ); + return DX::Step::ResolveProposition->new(resolution_space => $self); } 1; diff --git a/lib/DX/Role/Predicate.pm b/lib/DX/Role/Predicate.pm index 0612168..a8e86a6 100644 --- a/lib/DX/Role/Predicate.pm +++ b/lib/DX/Role/Predicate.pm @@ -1,7 +1,5 @@ package DX::Role::Predicate; -use List::Util qw(reduce); -use DX::Utils qw(step CONTENTS_OF); use DX::Role; sub resolution_step_for { diff --git a/lib/DX/Step/ResolveProposition.pm b/lib/DX/Step/ResolveProposition.pm index 1b4cd26..3416c27 100644 --- a/lib/DX/Step/ResolveProposition.pm +++ b/lib/DX/Step/ResolveProposition.pm @@ -4,13 +4,15 @@ use DX::Step::EnterRecheck; use DX::Step::Backtrack; use Types::Standard qw(ArrayRef); -use DX::Utils qw(deparse step); use DX::Class; with 'DX::Role::Step'; -has resolves => (is => 'ro', isa => Proposition); +has resolves => (is => 'lazy', init_arg => undef, builder => sub { + my ($self) = @_; + $self->resolution_space->proposition; +}); has resolution_space => (is => 'ro', isa => ResolutionSpace); @@ -41,10 +43,7 @@ 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 step( - resolves => $self->resolves, - resolution_space => $rspace - ); + return $rspace->next_step; }); sub but_first { diff --git a/lib/DX/Utils.pm b/lib/DX/Utils.pm index efdc259..0391df3 100644 --- a/lib/DX/Utils.pm +++ b/lib/DX/Utils.pm @@ -10,7 +10,7 @@ my @const = ( our @EXPORT_OK = ( @const, - (my @builders = qw(step rspace rstrat res string number dict proposition)), + (my @builders = qw(rspace rstrat res string number dict proposition)), 'deparse', '*trace', ); @@ -56,15 +56,6 @@ sub _expand_deps { [ map _expand_dep($_), @{$_[0]} ] } -sub step { - require DX::Step::ResolveProposition; - my %args = @_; - DX::Step::ResolveProposition->new( - %args, - depends_on => _expand_deps($args{depends_on}), - ); -} - sub rspace { require DX::ResolutionSpace; DX::ResolutionSpace->new(@_);