Specio::Library::Structured - Online Linux Manual PageSection : 3
Updated : 2022-01-21
Source : perl v5.34.0
Note : User Contributed Perl Documentation
NAMESpecio::Library::Structured − Structured types for Specio (Dict, Map, Tuple)
VERSIONversion 0.47
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'),
},
},
);
DESCRIPTIONThis 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, Dict, Map, and Tuple. This library also exports two helper subs used for some types, optional and slurpy. All structured types are parameterized by calling t( 'Type Name', of => ... ). The arguments passed after of vary for each type.
DictA Dict is a hashref with a well-defined set of keys and types for those key. The argument passed to of should be a single hashref. That hashref must contain a kv key defining the expected keys and the types for their values. This kv value is itself a hashref. If a key/value pair is optional, use optional around the 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 undef. You can also pass a slurpy key. If this is passed, then the 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'),
},
);
MapA Map is a hashref with specified types for its keys and values, but no well-defined key names. The argument passed to of should be a single hashref with two keys, key and value. The type for the 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.
TupleA Tuple is an arrayref with a fixed set of members in a specific order. The argument passed to of should be a single arrayref consisting of types. You can mark a slot in the Tuple as optional by wrapping the type in a call to optional: my $record = t(
'Tuple',
of => [
t('PositiveInt'),
t('Str'),
optional( t('Num') ),
optional( t('Num') ),
],
);
You can have as many 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 slurpy: my $record = t(
'Tuple',
of => [
t('PositiveInt'),
t('Str'),
slurpy( t('Num') ),
],
);
In this case, the Tuple will require the first two elements and then allow any number (including zero) of Num elements. You cannot mix optional and slurpy in a Tuple definition.
LIMITATIONSCurrently 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.
SUPPORTBugs may be submitted at <https://github.com/houseabsolute/Specio/issues>. I am also usually active on IRC as 'autarch' on irc://irc.perl.org.
SOURCEThe source code repository for Specio can be found at <https://github.com/houseabsolute/Specio>.
AUTHORDave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSEThis software is Copyright (c) 2012 − 2021 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 LICENSE file included with this distribution. 0
Johanes Gumabo
Data Size : 18,247 byte
man-Specio::Library::Structured.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 190,257
Visitor ID : :
Visitor IP : 52.14.7.103 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Specio::Library::Structured.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Specio::Library::Structured.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Specio::Library::Structured.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Specio::Library::Structured.3pm|43|'br══─}─══ |'br══─}─══
)