From: Matt S Trout Date: Thu, 16 Feb 2017 19:37:20 +0000 (+0000) Subject: add a few more type annotations X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=80d78e1b96b3db270c57269ab0bb41db584e1170;p=scpubgit%2FDX.git add a few more type annotations --- diff --git a/lib/DX/ResolvedPropositionSet.pm b/lib/DX/ResolvedPropositionSet.pm index 357186b..74b29db 100644 --- a/lib/DX/ResolvedPropositionSet.pm +++ b/lib/DX/ResolvedPropositionSet.pm @@ -1,7 +1,7 @@ package DX::ResolvedPropositionSet; use DX::DependencyMap; -use Types::Standard qw(ArrayRef); +use Types::Standard qw(ArrayRef Int); use DX::Utils qw(deparse); use DX::Class; @@ -9,7 +9,7 @@ has dependency_map => (is => 'ro', isa => DependencyMap, required => 1); has propositions => (is => 'ro', isa => ArrayRef[Proposition], required => 1); -has scope_depth => (is => 'ro', required => 1); +has scope_depth => (is => 'ro', isa => Int, required => 1); sub resolved_count { scalar @{$_[0]->propositions} } diff --git a/lib/DX/Scope.pm b/lib/DX/Scope.pm index c18022a..ea0914f 100644 --- a/lib/DX/Scope.pm +++ b/lib/DX/Scope.pm @@ -1,6 +1,6 @@ package DX::Scope; -use Types::Standard qw(HashRef ArrayRef); +use Types::Standard qw(HashRef ArrayRef Str); use DX::Class; has predicates => (is => 'ro', isa => HashRef[Predicate], required => 1); @@ -9,7 +9,7 @@ has globals => (is => 'ro', isa => DictValue, required => 1); has locals => (is => 'ro', isa => ArrayRef[DictValue], required => 1); -has lex_map => (is => 'ro', isa => HashRef, required => 1); +has lex_map => (is => 'ro', isa => HashRef[ArrayRef[Str]], required => 1); #has known_facts => (is => 'ro', required => 1); diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index 0a306c9..ced6067 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -1,6 +1,6 @@ package DX::SearchState; -use Types::Standard qw(Maybe); +use Types::Standard qw(Maybe Bool); use DX::Step::Backtrack; use DX::Step::ConsiderProposition; use DX::Step::MarkAsSolution; @@ -14,7 +14,7 @@ has propositions => (is => 'ro', isa => PropositionSequence, required => 1); has adjustments_made => (is => 'ro', isa => AdjustmentList, required => 1); -has is_solution_state => (is => 'ro', required => 1); +has is_solution_state => (is => 'ro', isa => Bool, required => 1); has on_exhaustion_step => (is => 'ro', isa => Maybe[Step], required => 1); diff --git a/lib/DX/ShellFrontend.pm b/lib/DX/ShellFrontend.pm index 1b8c66e..29eac40 100644 --- a/lib/DX/ShellFrontend.pm +++ b/lib/DX/ShellFrontend.pm @@ -1,15 +1,16 @@ package DX::ShellFrontend; +use Types::Standard qw(Enum); use IO::Handle; use Caroline; use DX::Class; has session => ( - is => 'ro', required => 1, + is => 'ro', isa => ShellSession, required => 1, handles => [ qw(is_complete_command_string eval_command_string) ] ); -has session_mode => (is => 'rwp', required => 1); +has session_mode => (is => 'rwp', isa => Enum['shell','query'], required => 1); has readline => (is => 'lazy', builder => sub { Caroline->new });