This file is indexed.

/usr/share/perl5/Specio/Library/Structured.pm is in libspecio-perl 0.42-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
package Specio::Library::Structured;

use strict;
use warnings;

our $VERSION = '0.42';

use parent 'Specio::Exporter';

use B ();
use Carp qw( confess );
use List::Util ();
use Scalar::Util qw( blessed );
use Specio::Constraint::Structurable;
use Specio::Declare;
use Specio::Library::Builtins;
use Specio::Library::Structured::Dict;
use Specio::Library::Structured::Map;
use Specio::Library::Structured::Tuple;
use Specio::TypeChecks qw( does_role );

## no critic (Variables::ProtectPrivateVars)
declare(
    'Dict',
    type_class => 'Specio::Constraint::Structurable',
    parent     => Specio::Library::Structured::Dict->parent,
    inline     => \&Specio::Library::Structured::Dict::_inline,
    parameterization_args_builder =>
        \&Specio::Library::Structured::Dict::_parameterization_args_builder,
    name_builder => \&Specio::Library::Structured::Dict::_name_builder,
    structured_inline_generator =>
        \&Specio::Library::Structured::Dict::_structured_inline_generator,
);

declare(
    'Map',
    type_class => 'Specio::Constraint::Structurable',
    parent     => Specio::Library::Structured::Map->parent,
    inline     => \&Specio::Library::Structured::Map::_inline,
    parameterization_args_builder =>
        \&Specio::Library::Structured::Map::_parameterization_args_builder,
    name_builder => \&Specio::Library::Structured::Map::_name_builder,
    structured_inline_generator =>
        \&Specio::Library::Structured::Map::_structured_inline_generator,
);

declare(
    'Tuple',
    type_class => 'Specio::Constraint::Structurable',
    parent     => Specio::Library::Structured::Tuple->parent,
    inline     => \&Specio::Library::Structured::Tuple::_inline,
    parameterization_args_builder =>
        \&Specio::Library::Structured::Tuple::_parameterization_args_builder,
    name_builder => \&Specio::Library::Structured::Tuple::_name_builder,
    structured_inline_generator =>
        \&Specio::Library::Structured::Tuple::_structured_inline_generator,
);
## use critic

sub optional {
    return { optional => shift };
}

sub slurpy {
    return { slurpy => shift };
}

## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
sub _also_export {qw( optional slurpy )}
## use critic

1;

# ABSTRACT: Structured types for Specio (Dict, Map, Tuple)

__END__

=pod

=encoding UTF-8

=head1 NAME

Specio::Library::Structured - Structured types for Specio (Dict, Map, Tuple)

=head1 VERSION

version 0.42

=head1 SYNOPSIS

    use Specio::Library::Builtins;
    use Specio::Library::String;
    use Specio::Library::Structured;

    my $map = t(
        'Map',
        of => {
            key   => t('NonEmptyStr'),
            value => t('Int'),
        },
    );
    my $tuple = t(
        'Tuple',
        of => [ t('Str'), t('Num') ],
    );
    my $dict = t(
        'Dict',
        of => {
            kv => {
                name => t('Str'),
                age  => t('Int'),
            },
        },
    );

=head1 DESCRIPTION

B<This particular library should be considered in an alpha state. The syntax
for defining structured types may change, as well as some of the internals of
its implementation.>

This library provides a set of structured types for Specio, C<Dict>, C<Map>,
and C<Tuple>. This library also exports two helper subs used for some types,
C<optional> and C<slurpy>.

All structured types are parameterized by calling C<< t( 'Type Name', of =>
... ) >>. The arguments passed after C<of> vary for each type.

=head2 Dict

A C<Dict> is a hashref with a well-defined set of keys and types for those
key.

The argument passed to C<of> should be a single hashref. That hashref must
contain a C<kv> key defining the expected keys and the types for their
values. This C<kv> value is itself a hashref. If a key/value pair is optional,
use C<optional> around the I<type> for that key:

    my $person = t(
        'Dict',
        of => {
            kv => {
                first  => t('NonEmptyStr'),
                middle => optional( t('NonEmptyStr') ),
                last   => t('NonEmptyStr'),
            },
        },
    );

If a key is optional, then it can be omitted entirely, but if it passed then
it's type will be checked, so it cannot just be set to C<undef>.

You can also pass a C<slurpy> key. If this is passed, then the C<Dict> will
allow other, unknown keys, as long as they match the specified type:

    my $person = t(
        'Dict',
        of => {
            kv => {
                first  => t('NonEmptyStr'),
                middle => optional( t('NonEmptyStr') ),
                last   => t('NonEmptyStr'),
            },
            slurpy => t('Int'),
        },
    );

=head2 Map

A C<Map> is a hashref with specified types for its keys and values, but no
well-defined key names.

The argument passed to C<of> should be a single hashref with two keys, C<key>
and C<value>. The type for the C<key> will typically be some sort of key, but
if you're using a tied hash or an object with hash overloading it could
conceivably be any sort of value.

=head2 Tuple

A C<Tuple> is an arrayref with a fixed set of members in a specific order.

The argument passed to C<of> should be a single arrayref consisting of
types. You can mark a slot in the C<Tuple> as optional by wrapping the type in
a call to C<optional>:

    my $record = t(
        'Tuple',
        of => [
            t('PositiveInt'),
            t('Str'),
            optional( t('Num') ),
            optional( t('Num') ),
        ],
    );

You can have as many C<optional> elements as you want, but they must always
come in sequence at the end of the tuple definition. You cannot interleave
required and optional elements.

You can also make the Tuple accept an arbitrary number of values by wrapping
the last type in a call to C<slurpy>:

    my $record = t(
        'Tuple',
        of => [
            t('PositiveInt'),
            t('Str'),
            slurpy( t('Num') ),
        ],
    );

In this case, the C<Tuple> will require the first two elements and then allow
any number (including zero) of C<Num> elements.

You cannot mix C<optional> and C<slurpy> in a C<Tuple> definition.

=for Pod::Coverage optional slurpy

=head1 LIMITATIONS

Currently all structured types require that the types they are structured with
can be inlined. This may change in the future, but inlining all your types is
a really good idea, so you should do that anyway.

=head1 SUPPORT

Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>.

I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.

=head1 SOURCE

The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>.

=head1 AUTHOR

Dave Rolsky <autarch@urth.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 - 2017 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the
F<LICENSE> file included with this distribution.

=cut