1Specio::Constraint::StrUuscetrurCaobnlter(i3b)uted PerlSDpoeccuimoe:n:tCaotnisotnraint::Structurable(3)
2
3
4

NAME

6       Specio::Constraint::Structurable - A class which represents
7       structurable constraints
8

VERSION

10       version 0.48
11

SYNOPSIS

13           my $tuple = t('Tuple');
14
15           my $tuple_of_str_int = $tuple->parameterize( of => [ t('Str'), t('Int') ] );
16

DESCRIPTION

18       This class implements the API for structurable types like "Dict",
19       "Map"< and "Tuple".
20

API

22       This class implements the same API as Specio::Constraint::Simple, with
23       a few additions.
24
25   Specio::Constraint::Structurable->new(...)
26       This class's constructor accepts two additional parameters:
27
28       •   parameterization_args_builder
29
30           This is a subroutine that takes the values passed to "of" and
31           returns a hash of named arguments. These arguments will then be
32           passed into the "structured_constraint_generator" or
33           "structured_inline_generator".
34
35           This should also do argument checking to make sure that the
36           argument passed are valid. For example, the "Tuple" type turns the
37           arrayref passed to "of" into a hash, along the way checking that
38           the caller did not do things like interleave optional and required
39           elements or mix optional and slurpy together in the definition.
40
41           This parameter is required.
42
43       •   name_builder
44
45           This is a subroutine that is called to generate a name for the
46           structured type when it is created. This will be called as a method
47           on the "Specio::Constraint::Structurable" object. It will be passed
48           the hash of arguments returned by the
49           "parameterization_args_builder".
50
51           This parameter is required.
52
53       •   structured_constraint_generator
54
55           This is a subroutine that generates a new constraint subroutine
56           when the type is structured.
57
58           It will be called as a method on the type and will be passed the
59           hash of arguments returned by the "parameterization_args_builder".
60
61           This parameter is mutually exclusive with the
62           "structured_inline_generator" parameter.
63
64           This parameter or the "structured_inline_generator" parameter is
65           required.
66
67       •   structured_inline_generator
68
69           This is a subroutine that generates a new inline generator
70           subroutine when the type is structured.
71
72           It will be called as a method on the Specio::Constraint::Structured
73           object when that object needs to generate an inline constraint. It
74           will receive the type parameter as the first argument and the
75           variable name as a string as the second.
76
77           The remaining arguments will be the parameter hash returned by the
78           "parameterization_args_builder".
79
80           This probably seems fairly confusing, so looking at the examples in
81           the Specio::Library::Structured::* code may be helpful.
82
83           This parameter is mutually exclusive with the
84           "structured_constraint_generator" parameter.
85
86           This parameter or the "structured_constraint_generator" parameter
87           is required.
88
89   $type->parameterize(...)
90       This method takes two arguments. The "of" argument should be an object
91       which does the Specio::Constraint::Role::Interface role, and is
92       required.
93
94       The other argument, "declared_at", is optional. If it is not given,
95       then a new Specio::DeclaredAt object is creating using a call stack
96       depth of 1.
97
98       This method returns a new Specio::Constraint::Structured object.
99

SUPPORT

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

SOURCE

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

AUTHOR

109       Dave Rolsky <autarch@urth.org>
110
112       This software is Copyright (c) 2012 - 2022 by Dave Rolsky.
113
114       This is free software, licensed under:
115
116         The Artistic License 2.0 (GPL Compatible)
117
118       The full text of the license can be found in the LICENSE file included
119       with this distribution.
120
121
122
123perl v5.36.0                      2023-01-20Specio::Constraint::Structurable(3)
Impressum