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