return $line;
}
sub history_add {}
+ sub isa { require Caroline; return 1 if Caroline->isa($_[1]); }
}
use_module('DX::ShellFrontend')->new(
with 'DX::Role::SimpleAction';
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
sub _build__updates {
my ($self) = @_;
- DX::Update::AddValue->new(
- target_path => $self->target_path,
- new_value => $self->new_value,
- );
+ [
+ DX::Update::AddValue->new(
+ target_path => $self->target_path,
+ new_value => $self->new_value,
+ )
+ ]
}
1;
with 'DX::Role::SimpleAction';
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
sub for_deparse {
my ($self) = @_;
sub _build__updates {
my ($self) = @_;
- DX::Update::SetValue->new(
- target_path => $self->target_path,
- new_value => $self->new_value,
- );
+ [
+ DX::Update::SetValue->new(
+ target_path => $self->target_path,
+ new_value => $self->new_value,
+ )
+ ]
}
1;
with 'DX::Role::SimpleAction';
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
sub _build__updates {
my ($self) = @_;
- DX::Update::SetValue->new(
- target_path => $self->target_path,
- new_value => $self->new_value,
- );
+ [
+ DX::Update::SetValue->new(
+ target_path => $self->target_path,
+ new_value => $self->new_value,
+ )
+ ]
}
1;
with 'DX::Role::ActionBuilder';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
-has rebind_path => (is => 'ro', required => 1);
+has rebind_path => (is => 'ro', required => 1, isa => ValuePath);
-has bound_to_path => (is => 'ro', required => 1);
+has bound_to_path => (is => 'ro', required => 1, isa => ValuePath);
-has inner_action_builder => (is => 'ro', required => 1);
+has inner_action_builder => (
+ is => 'ro', required => 1, isa => ActionBuilder
+);
sub can_set_value { shift->inner_action_builder->can_set_value }
with 'DX::Role::ActionBuilder';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
sub aperture_for_set_value {
[ [ VALUE_SET ,=> @{$_[0]->target_path} ] ]
with 'DX::Role::ActionBuilder';
-has target_path => (is => 'ro');
-
-around target_path => sub {
- my ($orig, $self) = (shift, shift);
- return undef unless ref($self);
- return $self->$orig(@_);
-};
+has target_path => (is => 'ro', isa => ValuePath);
sub can_set_value { 0 }
with 'DX::Role::ActionBuilder';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
-has proxy_to => (is => 'ro', required => 1);
+has proxy_to => (is => 'ro', required => 1, isa => ActionBuilder);
sub aperture_for_set_value {
my ($self) = @_;
with 'DX::Role::ActionBuilder';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
sub aperture_for_set_value {
[ [ VALUE_SET ,=> @{$_[0]->target_path} ] ]
strictures->import::into({ level => 1, version => 2 }); # should pass version
DX::Types->import::into(1, ':types', ':assert');
DX::Utils->import::into(1, '*trace');
- Types::Standard->import::into(1, 'Maybe');
+ Types::Standard->import::into(
+ 1, qw(Maybe ArrayRef HashRef Str Num Int Enum Bool)
+ );
Try::Tiny->import::into(1);
Moo->import::into(1);
# This would not be safe with method modifiers, but since the role
package DX::Hypothesis;
use DX::ActionPolicy::LockScope;
-use Types::Standard qw(ArrayRef);
use DX::Utils qw(deparse);
use DX::Class;
package DX::Proposition;
-use Types::Standard qw(HashRef ArrayRef Str);
use DX::Class;
has predicate => (is => 'ro', isa => Str, required => 1);
package DX::PropositionSequence;
-use Types::Standard qw(HashRef);
use DX::Class;
has members => (is => 'ro', isa => PropositionList, required => 1);
package DX::QueryState;
-use Types::Standard qw(HashRef);
use DX::Scope;
use DX::Hypothesis;
use DX::SearchProcess;
package DX::ResolvedPropositionSet;
use DX::DependencyMap;
-use Types::Standard qw(ArrayRef Int);
use DX::Utils qw(deparse);
use DX::Class;
strictures->import::into({ level => 1, version => 2 });
DX::Types->import::into(1, ':types', ':assert');
DX::Utils->import::into(1, '*trace');
- Types::Standard->import::into(1, 'Maybe');
+ Types::Standard->import::into(
+ 1, qw(Maybe ArrayRef HashRef Str Num Enum Bool)
+ );
Try::Tiny->import::into(1);
Moo::Role->import::into(1);
}
with 'DX::Role::Action';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
-has bound_to_path => (is => 'ro', required => 1);
+has bound_to_path => (is => 'ro', required => 1, isa => ValuePath);
-has rebind_path => (is => 'ro', required => 1);
+has rebind_path => (is => 'ro', required => 1, isa => ValuePath);
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
-has inner_action => (is => 'ro', required => 1);
+has inner_action => (is => 'ro', required => 1, isa => Action);
requires 'update_class';
with 'DX::Role::Action';
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
-has _updates => (is => 'lazy');
+has _updates => (is => 'lazy', isa => ArrayRef[Update]);
requires '_build__updates';
sub dry_run {
my ($self, $hyp) = @_;
- my ($scope, @events) = $hyp->scope->apply_updates($self->_updates);
+ my ($scope, @events) = $hyp->scope->apply_updates(@{$self->_updates});
return (
$hyp->but(
scope => $scope,
use DX::Role;
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
sub _with_value_at_path {
my ($self, $scope, $final_value, @path) = @_;
use DX::ActionBuilder::Null;
use DX::Role;
+my $_null = DX::ActionBuilder::Null->new;
+
has action_builder => (
is => 'ro',
- default => 'DX::ActionBuilder::Null',
+ isa => ActionBuilder,
+ default => sub { $_null },
handles => [ qw(can_set_value aperture_for_set_value action_for_set_value) ],
);
package DX::Scope;
-use Types::Standard qw(HashRef ArrayRef Str);
use DX::Class;
has predicates => (is => 'ro', isa => HashRef[Predicate], required => 1);
package DX::SearchState;
-use Types::Standard qw(Maybe Bool);
use DX::Step::Backtrack;
use DX::Step::ConsiderProposition;
use DX::Step::MarkAsSolution;
package DX::ShellFrontend;
-use Types::Standard qw(Enum);
use IO::Handle;
+use Types::Standard qw(InstanceOf);
use Caroline;
use DX::Class;
has session_mode => (is => 'rwp', isa => Enum['shell','query'], required => 1);
-has readline => (is => 'lazy', builder => sub { Caroline->new });
+has readline => (
+ is => 'lazy', isa => InstanceOf['Caroline'],
+ builder => sub { Caroline->new }
+);
sub BUILD { STDOUT->autoflush(1) }
use DX::ActionBuilder::Normal;
use DX::RuleDefinitionContext;
use DX::Utils qw(deparse);
+use Types::Standard qw(InstanceOf);
use DX::Class;
has shell_state => (is => 'rwp', required => 1, isa => ShellState);
has expander => (
is => 'lazy', builder => sub { DX::Expander->new(tcl => $_[0]->tcl) },
- handles => [ qw(expand_args) ],
+ isa => InstanceOf['DX::Expander'], handles => [ qw(expand_args) ],
);
-has tcl => (is => 'lazy', builder => sub {
+has tcl => (is => 'lazy', isa => InstanceOf['Tcl'], builder => sub {
my ($self) = @_;
weaken $self;
my $tcl = Tcl->new;
use DX::Step::EnterRecheck;
use DX::Step::Backtrack;
-use Types::Standard qw(ArrayRef);
use DX::Utils qw(expand_deps);
use DX::Class;
our $Extra = 0;
has ambient_indent_level => (
- is => 'rwp', lazy => 1, clearer => 1, default => 0
+ is => 'rwp', lazy => 1, clearer => 1, default => 0, isa => Int
);
sub indent_by { ' ' }
ResolutionSpace ResolutionStrategy Resolution
)),
(our @ROLES = qw(
- Step Action ActionPolicy Predicate Value
+ Step Action ActionPolicy Predicate Value ActionBuilder Update
)),
qw(
DependencyType _DependencyTree DependencySpec
- One DependencyGroupEntry DependencyGroup
+ One DependencyGroupEntry DependencyGroup ValuePath
),
)
;
class_type DictValue => { class => 'DX::Value::Dict' };
+declare ValuePath => as ArrayRef[Str];
+
declare PropositionList => as ArrayRef[Proposition];
declare DecisionList => as ArrayRef[Tuple[ResolutionSpace, SearchState]];
with 'DX::Role::Update';
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
sub apply_to {
my ($self, $scope) = @_;
with 'DX::Role::Update';
-has new_value => (is => 'ro', required => 1);
+has new_value => (is => 'ro', required => 1, isa => Value);
sub apply_to {
my ($self, $scope) = @_;
) ]
);
-has members => (is => 'ro', required => 1);
+has members => (is => 'ro', required => 1, isa => HashRef[Value]);
sub for_deparse {
[ dict => $_[0]->members ]
with 'DX::Role::Value';
-has number_value => (is => 'ro', required => 1);
+has number_value => (is => 'ro', required => 1, isa => Num);
sub for_deparse { [ number => $_[0]->number_value ] }
with 'DX::Role::Value';
-has string_value => (is => 'ro', required => 1);
+has string_value => (is => 'ro', required => 1, isa => Str);
sub for_deparse { [ string => $_[0]->string_value ] }