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 |
9eedd677 |
9 | PropositionSequence QueryState ShellState ShellSession |
3e465d5d |
10 | )), |
11 | (our @ROLES = qw( |
12 | Step Action ActionPolicy Predicate Value |
13 | )), |
14 | qw( |
15 | DependencyType _DependencyTree DependecySpec |
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 | |
36 | declare AlternativeList => as ArrayRef[Tuple[Hypothesis, Step]]; |
37 | |
38 | declare DependencyType => where { |
d5511afa |
39 | foreach my $cand (EXISTENCE_OF, TYPE_OF, INDICES_OF, CONTENTS_OF) { |
3e465d5d |
40 | return 1 if $_ eq $cand; |
41 | } |
42 | return 0; |
43 | }; |
44 | |
45 | declare EventType => where { |
46 | foreach my $cand (VALUE_SET, VALUE_EXISTS) { |
47 | return 1 if $_ eq $cand; |
48 | } |
49 | return 0; |
50 | }; |
51 | |
52 | declare _DependencyTree => where { is_DependencyTree($_) }; |
53 | |
54 | declare DependencySpec => as Tuple[DependencyType, slurpy ArrayRef[Str]]; |
55 | |
56 | declare One => where { !ref($_) and $_ eq 1 }; |
57 | |
58 | declare DependencyTree => # [ \%subtree, \%existence_of, ... ] |
59 | as HashRef[Tuple[ |
60 | Maybe[_DependencyTree], |
61 | (Optional[Maybe[HashRef[One]]]) x 4 |
62 | ]]; |
63 | |
64 | declare DependencyGroupEntry => |
65 | as Tuple[DependencyType, slurpy ArrayRef[Value|Str]]; |
66 | |
67 | declare DependencyGroup => |
68 | as Tuple[Maybe[Value], slurpy ArrayRef[DependencyGroupEntry]]; |
69 | |
70 | declare DependencyGroupList => as ArrayRef[DependencyGroup]; |
71 | |
72 | 1; |