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 |
cfae7810 |
10 | ResolutionSpace ResolutionStrategy Resolution Expander SearchProcess |
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 |
cfae7810 |
18 | EventType ApertureList DependencyList ShellMode |
3e465d5d |
19 | ), |
20 | ) |
21 | ; |
22 | use Type::Utils -all; |
23 | use Types::Standard qw( |
cfae7810 |
24 | ArrayRef Tuple HashRef Dict Maybe Optional slurpy Str Enum |
3e465d5d |
25 | ); |
26 | use DX::Utils qw(:event_types :dep_types); |
27 | |
28 | foreach my $class (our @CLASSES) { |
29 | class_type $class => { class => 'DX::'.$class }; |
30 | } |
31 | |
32 | foreach my $role (our @ROLES) { |
33 | role_type $role => { role => 'DX::Role::'.$role }; |
34 | } |
35 | |
36 | class_type DictValue => { class => 'DX::Value::Dict' }; |
37 | |
2548ce61 |
38 | declare ValuePath => as ArrayRef[Str]; |
39 | |
d6fabec9 |
40 | declare PropositionList => as ArrayRef[Proposition]; |
41 | |
1c02730b |
42 | declare DecisionList => as ArrayRef[Tuple[ResolutionSpace, SearchState]]; |
3e465d5d |
43 | |
44 | declare DependencyType => where { |
d5511afa |
45 | foreach my $cand (EXISTENCE_OF, TYPE_OF, INDICES_OF, CONTENTS_OF) { |
3e465d5d |
46 | return 1 if $_ eq $cand; |
47 | } |
48 | return 0; |
49 | }; |
50 | |
51 | declare EventType => where { |
52 | foreach my $cand (VALUE_SET, VALUE_EXISTS) { |
53 | return 1 if $_ eq $cand; |
54 | } |
55 | return 0; |
56 | }; |
57 | |
58 | declare _DependencyTree => where { is_DependencyTree($_) }; |
59 | |
22d29594 |
60 | declare DependencySpec => as Tuple[DependencyType, slurpy ValuePath]; |
3e465d5d |
61 | |
d6fabec9 |
62 | declare DependencyList => as ArrayRef[DependencySpec]; |
63 | |
3e465d5d |
64 | declare One => where { !ref($_) and $_ eq 1 }; |
65 | |
66 | declare DependencyTree => # [ \%subtree, \%existence_of, ... ] |
67 | as HashRef[Tuple[ |
68 | Maybe[_DependencyTree], |
69 | (Optional[Maybe[HashRef[One]]]) x 4 |
70 | ]]; |
71 | |
22d29594 |
72 | declare ApertureList => as ArrayRef[Tuple[EventType, slurpy ValuePath]]; |
73 | |
cfae7810 |
74 | declare ShellMode => as Enum[qw(shell query)]; |
75 | |
9acbb80f |
76 | ## These were from the dependency group thing which makes no sense until |
77 | ## we have scoping, so revisit it then |
78 | # |
79 | #declare DependencyGroupEntry => |
80 | # as Tuple[DependencyType, slurpy ArrayRef[Value|Str]]; |
81 | # |
82 | #declare DependencyGroup => |
83 | # as Tuple[Maybe[Value], slurpy ArrayRef[DependencyGroupEntry]]; |
84 | # |
85 | #declare DependencyGroupList => as ArrayRef[DependencyGroup]; |
3e465d5d |
86 | |
87 | 1; |