Commit | Line | Data |
3e465d5d |
1 | package DX::Types; |
2 | |
3 | use strictures 2; |
4 | use Type::Library |
5 | -base, |
6 | -declare => ( |
7 | (our @CLASSES = qw( |
8 | Hypothesis Scope ResolvedPropositionSet Proposition DependencyMap |
8c16d3c9 |
9 | PropositionSequence QueryState ShellState ShellSession SearchState |
839c0018 |
10 | ResolutionSpace ResolutionStrategy Resolution |
3e465d5d |
11 | )), |
12 | (our @ROLES = qw( |
2548ce61 |
13 | Step Action ActionPolicy Predicate Value ActionBuilder Update |
3e465d5d |
14 | )), |
15 | qw( |
d6fabec9 |
16 | DependencyType _DependencyTree DependencySpec |
2548ce61 |
17 | One DependencyGroupEntry DependencyGroup ValuePath |
3e465d5d |
18 | ), |
19 | ) |
20 | ; |
21 | use Type::Utils -all; |
22 | use Types::Standard qw( |
23 | ArrayRef Tuple HashRef Dict Maybe Optional slurpy Str |
24 | ); |
25 | use DX::Utils qw(:event_types :dep_types); |
26 | |
27 | foreach my $class (our @CLASSES) { |
28 | class_type $class => { class => 'DX::'.$class }; |
29 | } |
30 | |
31 | foreach my $role (our @ROLES) { |
32 | role_type $role => { role => 'DX::Role::'.$role }; |
33 | } |
34 | |
35 | class_type DictValue => { class => 'DX::Value::Dict' }; |
36 | |
2548ce61 |
37 | declare ValuePath => as ArrayRef[Str]; |
38 | |
d6fabec9 |
39 | declare PropositionList => as ArrayRef[Proposition]; |
40 | |
1c02730b |
41 | declare DecisionList => as ArrayRef[Tuple[ResolutionSpace, SearchState]]; |
3e465d5d |
42 | |
43 | declare DependencyType => where { |
d5511afa |
44 | foreach my $cand (EXISTENCE_OF, TYPE_OF, INDICES_OF, CONTENTS_OF) { |
3e465d5d |
45 | return 1 if $_ eq $cand; |
46 | } |
47 | return 0; |
48 | }; |
49 | |
50 | declare EventType => where { |
51 | foreach my $cand (VALUE_SET, VALUE_EXISTS) { |
52 | return 1 if $_ eq $cand; |
53 | } |
54 | return 0; |
55 | }; |
56 | |
57 | declare _DependencyTree => where { is_DependencyTree($_) }; |
58 | |
59 | declare DependencySpec => as Tuple[DependencyType, slurpy ArrayRef[Str]]; |
60 | |
d6fabec9 |
61 | declare DependencyList => as ArrayRef[DependencySpec]; |
62 | |
3e465d5d |
63 | declare One => where { !ref($_) and $_ eq 1 }; |
64 | |
65 | declare DependencyTree => # [ \%subtree, \%existence_of, ... ] |
66 | as HashRef[Tuple[ |
67 | Maybe[_DependencyTree], |
68 | (Optional[Maybe[HashRef[One]]]) x 4 |
69 | ]]; |
70 | |
9acbb80f |
71 | ## These were from the dependency group thing which makes no sense until |
72 | ## we have scoping, so revisit it then |
73 | # |
74 | #declare DependencyGroupEntry => |
75 | # as Tuple[DependencyType, slurpy ArrayRef[Value|Str]]; |
76 | # |
77 | #declare DependencyGroup => |
78 | # as Tuple[Maybe[Value], slurpy ArrayRef[DependencyGroupEntry]]; |
79 | # |
80 | #declare DependencyGroupList => as ArrayRef[DependencyGroup]; |
3e465d5d |
81 | |
82 | 1; |