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