finish adding type constraints
[scpubgit/DX.git] / lib / DX / ResolutionStrategy.pm
index ac54832..18126f0 100644 (file)
@@ -1,22 +1,21 @@
 package DX::ResolutionStrategy;
 
 use DX::Resolution;
+use Types::Standard qw(CodeRef Tuple slurpy);
 use DX::Class;
 
-has action_prototypes => (is => 'ro', required => 1);
+has action_prototypes => (
+  is => 'ro', required => 1,
+  isa => ArrayRef[Tuple[Value, Str, slurpy ArrayRef[Value]]]
+);
 
-has veracity_depends_on_builder => (is => 'ro', required => 1);
+has veracity_depends_on_builder => (
+  is => 'ro', required => 1, isa => CodeRef
+);
 
-has implementation_candidates => (is => 'ro', required => 1);
-
-has aperture => (is => 'lazy', builder => sub {
-  my ($self) = @_;
-  return [
-    # [ $thing, 'set_value' ] -> $thing->aperture_for_set_value
-    map @{$_->[0]->${\'aperture_for_'.$_[1]}()},
-      @{$self->action_prototypes}
-  ];
-});
+has implementation_candidates => (
+  is => 'ro', required => 1, isa => ArrayRef[ArrayRef[ArrayRef[Value]]]
+);
 
 sub next_resolution {
   my ($self) = @_;
@@ -43,8 +42,8 @@ sub remainder {
 
 sub for_deparse {
   my ($self) = @_;
-  [ statement => [
-    [ symbol => 'resolution_strategy' ],
+  [ word_and_body => [
+    'resolution_strategy',
     [ pairs => [
       [ action_prototypes => [ block => [
         map {
@@ -56,9 +55,9 @@ sub for_deparse {
           ] ]
         } @{$self->action_prototypes}
       ] ] ],
-      [ implementation_candidates => [ block => [
-        map [ block => [
-          map [ block => [
+      [ implementation_candidates => [ list => [
+        map [ list => [
+          map [ list => [
             map +($_->value_path ? [ value_path => $_->value_path ] : $_), @$_
           ] ], @$_
         ] ], @{$self->implementation_candidates}