| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
191690
|
use 5.008; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
89
|
|
|
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
77
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
142
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Types::Set; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
2
|
|
|
2
|
|
6
|
$Types::Set::AUTHORITY = 'cpan:TOBYINK'; |
|
9
|
2
|
|
|
|
|
35
|
$Types::Set::VERSION = '0.003'; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
13
|
use Set::Equivalence (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
42
|
|
|
13
|
2
|
|
|
2
|
|
11
|
use Type::Tiny 0.014; |
|
|
2
|
|
|
|
|
43
|
|
|
|
2
|
|
|
|
|
77
|
|
|
14
|
2
|
|
|
2
|
|
12
|
use Type::Library -base, -declare => qw(Set AnySet MutableSet ImmutableSet); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
19
|
|
|
15
|
2
|
|
|
2
|
|
1736
|
use Types::Standard qw(ArrayRef InstanceOf HasMethods); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
18
|
|
|
16
|
2
|
|
|
2
|
|
4890
|
use Type::Utils -all; |
|
|
2
|
|
|
|
|
11569
|
|
|
|
2
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
declare Set, |
|
19
|
|
|
|
|
|
|
as InstanceOf['Set::Equivalence'], |
|
20
|
|
|
|
|
|
|
_params(Set); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
declare AnySet, |
|
23
|
|
|
|
|
|
|
as HasMethods[qw( insert delete members contains )]; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
declare MutableSet, |
|
26
|
|
|
|
|
|
|
as Set, |
|
27
|
|
|
|
|
|
|
where { $_->is_mutable }, |
|
28
|
|
|
|
|
|
|
inline_as { ( undef, "$_\->is_mutable" ) }, |
|
29
|
|
|
|
|
|
|
_params(MutableSet); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
declare ImmutableSet, |
|
32
|
|
|
|
|
|
|
as Set, |
|
33
|
|
|
|
|
|
|
where { $_->is_immutable }, |
|
34
|
|
|
|
|
|
|
inline_as { ( undef, "$_\->is_immutable" ) }, |
|
35
|
|
|
|
|
|
|
_params(ImmutableSet); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
coerce Set, |
|
38
|
|
|
|
|
|
|
from ArrayRef, q{ 'Set::Equivalence'->new(members => $_) }, |
|
39
|
|
|
|
|
|
|
from AnySet, q{ 'Set::Equivalence'->new(members => [$_->members]) }, |
|
40
|
|
|
|
|
|
|
; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
coerce AnySet, |
|
43
|
|
|
|
|
|
|
from ArrayRef, q{ 'Set::Equivalence'->new(members => $_) }, |
|
44
|
|
|
|
|
|
|
; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
coerce MutableSet, |
|
47
|
|
|
|
|
|
|
from ImmutableSet, q{ $_->clone }, |
|
48
|
|
|
|
|
|
|
from ArrayRef, q{ 'Set::Equivalence'->new(members => $_) }, |
|
49
|
|
|
|
|
|
|
from AnySet, q{ 'Set::Equivalence'->new(members => [$_->members]) }, |
|
50
|
|
|
|
|
|
|
; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
coerce ImmutableSet, |
|
53
|
|
|
|
|
|
|
from MutableSet, q{ $_->clone->make_immutable }, |
|
54
|
|
|
|
|
|
|
from ArrayRef, q{ 'Set::Equivalence'->new(mutable => !!0, members => $_) }, |
|
55
|
|
|
|
|
|
|
from AnySet, q{ 'Set::Equivalence'->new(mutable => !!0, members => [$_->members]) }, |
|
56
|
|
|
|
|
|
|
; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Crazy stuff for parameterization... |
|
59
|
|
|
|
|
|
|
sub _params |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
6
|
|
|
6
|
|
14997
|
my $basetype = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return( |
|
64
|
|
|
|
|
|
|
constraint_generator => sub { |
|
65
|
27
|
|
|
27
|
|
9016
|
my $parameter = Types::TypeTiny::TypeTiny->(shift); |
|
66
|
|
|
|
|
|
|
return sub { |
|
67
|
0
|
|
|
|
|
0
|
my $tc = $_->type_constraint; |
|
68
|
0
|
0
|
0
|
|
|
0
|
Scalar::Util::blessed($tc) and $tc->can('is_a_type_of') and $tc->is_a_type_of($parameter); |
|
69
|
27
|
|
|
|
|
988
|
}; |
|
70
|
|
|
|
|
|
|
}, |
|
71
|
|
|
|
|
|
|
inline_generator => sub { |
|
72
|
27
|
|
|
27
|
|
1237
|
our %REFADDR; |
|
73
|
27
|
|
|
|
|
74
|
my $parameter = Types::TypeTiny::TypeTiny->(shift); |
|
74
|
27
|
|
|
|
|
782
|
my $refaddr = Scalar::Util::refaddr($parameter); |
|
75
|
27
|
|
|
|
|
66
|
$REFADDR{$refaddr} = $parameter; |
|
76
|
|
|
|
|
|
|
return sub { |
|
77
|
|
|
|
|
|
|
return ( |
|
78
|
|
|
|
|
|
|
undef, |
|
79
|
30
|
|
|
|
|
11758
|
"do { my \$tc = $_\->type_constraint; Scalar::Util::blessed(\$tc) and \$tc->can('is_a_type_of') and \$tc->is_a_type_of(\$Types::Set::REFADDR{$refaddr}) }", |
|
80
|
|
|
|
|
|
|
); |
|
81
|
27
|
|
|
|
|
129
|
}; |
|
82
|
|
|
|
|
|
|
}, |
|
83
|
|
|
|
|
|
|
coercion_generator => sub { |
|
84
|
27
|
|
|
27
|
|
1960
|
my ($parent, $child, $parameter) = @_; |
|
85
|
27
|
|
|
|
|
158
|
my $coercions = 'Type::Coercion'->new( type_constraint => $child ); |
|
86
|
27
|
|
|
|
|
10065
|
my $immute = ($parent->name =~ /^Immutable/); |
|
87
|
|
|
|
|
|
|
|
|
88
|
27
|
100
|
|
|
|
175
|
if ($parameter->has_coercion) { |
|
89
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
90
|
|
|
|
|
|
|
ArrayRef() => sub { |
|
91
|
2
|
|
|
|
|
2609
|
my $in = $_; |
|
92
|
2
|
|
|
|
|
13
|
my $set = 'Set::Equivalence'->new( |
|
93
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
94
|
|
|
|
|
|
|
coerce => 1, |
|
95
|
|
|
|
|
|
|
members => [ map $parameter->coerce($_), @$in ], |
|
96
|
|
|
|
|
|
|
); |
|
97
|
2
|
50
|
|
|
|
17
|
$immute ? $set->make_immutable : $set; |
|
98
|
|
|
|
|
|
|
}, |
|
99
|
3
|
|
|
|
|
53
|
); |
|
100
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
101
|
|
|
|
|
|
|
Set() => sub { |
|
102
|
1
|
|
|
|
|
8
|
my $in = $_; |
|
103
|
1
|
|
|
|
|
5
|
my $set = 'Set::Equivalence'->new( |
|
104
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
105
|
|
|
|
|
|
|
coerce => 1, |
|
106
|
|
|
|
|
|
|
equivalence_relation => $in->equivalence_relation, |
|
107
|
|
|
|
|
|
|
members => [ map $parameter->coerce($_), $in->members ], |
|
108
|
|
|
|
|
|
|
); |
|
109
|
1
|
50
|
|
|
|
10
|
$immute ? $set->make_immutable : $set; |
|
110
|
|
|
|
|
|
|
}, |
|
111
|
3
|
|
|
|
|
693
|
); |
|
112
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
113
|
|
|
|
|
|
|
AnySet() => sub { |
|
114
|
0
|
|
|
|
|
0
|
my $in = $_; |
|
115
|
0
|
|
|
|
|
0
|
my $set = 'Set::Equivalence'->new( |
|
116
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
117
|
|
|
|
|
|
|
coerce => 1, |
|
118
|
|
|
|
|
|
|
members => [ map $parameter->coerce($_), $in->members ], |
|
119
|
|
|
|
|
|
|
); |
|
120
|
0
|
0
|
|
|
|
0
|
$immute ? $set->make_immutable : $set; |
|
121
|
|
|
|
|
|
|
}, |
|
122
|
3
|
|
|
|
|
248
|
); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
else { |
|
125
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
126
|
|
|
|
|
|
|
ArrayRef() => sub { |
|
127
|
0
|
|
|
|
|
0
|
my $in = $_; |
|
128
|
0
|
|
|
|
|
0
|
my $set = 'Set::Equivalence'->new( |
|
129
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
130
|
|
|
|
|
|
|
members => $in, |
|
131
|
|
|
|
|
|
|
); |
|
132
|
0
|
0
|
|
|
|
0
|
$immute ? $set->make_immutable : $set; |
|
133
|
|
|
|
|
|
|
}, |
|
134
|
24
|
|
|
|
|
342
|
); |
|
135
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
136
|
|
|
|
|
|
|
Set() => sub { |
|
137
|
0
|
|
|
|
|
0
|
my $in = $_; |
|
138
|
0
|
|
|
|
|
0
|
my $set = 'Set::Equivalence'->new( |
|
139
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
140
|
|
|
|
|
|
|
equivalence_relation => $in->equivalence_relation, |
|
141
|
|
|
|
|
|
|
members => [ $in->members ], |
|
142
|
|
|
|
|
|
|
); |
|
143
|
0
|
0
|
|
|
|
0
|
$immute ? $set->make_immutable : $set; |
|
144
|
|
|
|
|
|
|
}, |
|
145
|
24
|
|
|
|
|
2408
|
); |
|
146
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
147
|
|
|
|
|
|
|
AnySet() => sub { |
|
148
|
0
|
|
|
|
|
0
|
my $in = $_; |
|
149
|
0
|
|
|
|
|
0
|
my $set = 'Set::Equivalence'->new( |
|
150
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
151
|
|
|
|
|
|
|
members => [ $in->members ], |
|
152
|
|
|
|
|
|
|
); |
|
153
|
0
|
0
|
|
|
|
0
|
$immute ? $set->make_immutable : $set; |
|
154
|
|
|
|
|
|
|
}, |
|
155
|
24
|
|
|
|
|
1674
|
); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$coercions->add_type_coercions( |
|
159
|
|
|
|
|
|
|
$parameter => sub { |
|
160
|
0
|
|
|
|
|
|
my $in = $_; |
|
161
|
0
|
|
|
|
|
|
my $set = 'Set::Equivalence'->new( |
|
162
|
|
|
|
|
|
|
type_constraint => $parameter, |
|
163
|
|
|
|
|
|
|
coerce => $parameter->has_coercion, |
|
164
|
|
|
|
|
|
|
members => [ $in ], |
|
165
|
|
|
|
|
|
|
); |
|
166
|
0
|
0
|
|
|
|
|
$immute ? $set->make_immutable : $set; |
|
167
|
|
|
|
|
|
|
}, |
|
168
|
27
|
50
|
|
|
|
1830
|
) unless $parameter->is_a_type_of(Set()); |
|
169
|
|
|
|
|
|
|
}, |
|
170
|
6
|
|
|
|
|
115
|
); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Set -> has_coercion |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |