view release on metacpan or search on metacpan
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
i18n/Aion/Type.ru-en.po view on Meta::CPAN
msgid "Тип ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ."
msgstr "A type is equivalent to another type."
msgid "Тип не ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ."
msgstr "A type is not equivalent to another type."
msgid "Тип не Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑений Ñ Ð´ÑÑгим Ñипом."
msgstr "A type has no overlap with another type."
msgid "Тип Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑение или пеÑеÑеÑÐµÐ½Ð¸Ñ Ñ Ð´ÑÑгим Ñипом."
msgstr "A type has an intersection or intersections with another type."
msgid "СоздаÑÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ð±ÐµÐ· аÑгÑменÑов, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип."
msgstr "Creates a subroutine with no arguments that returns a type."
msgid "ÐÑли Ñказан `init` Ñо пÑи каждом иÑполÑзовании подпÑогÑÐ°Ð¼Ð¼Ñ Ð±ÑÐ´ÐµÑ ÑоздаваÑÑÑÑ Ñип и иниÑиализиÑоваÑÑÑÑ."
msgstr "If `init` is specified, then each time the subroutine is used, a type will be created and initialized."
msgid "Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ Ð°ÑгÑменÑами, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип."
msgstr "Creates a subroutine with arguments that returns a type."
i18n/Aion/Type.ru-en.po view on Meta::CPAN
msgid "ÐлониÑоваÑÑ Ñип."
msgstr "Clone type."
msgid "ÐÑо - пÑимиÑивнÑй Ñип, Ñо еÑÑÑ ÑоÑ, в иеÑаÑÑ
ии коÑоÑого Ð½ÐµÑ Ð¼Ð½Ð¾Ð¶ÐµÑÑвенно-ÑеоÑиÑиÑеÑкиÑ
опеÑаÑоÑов."
msgstr "This is a primitive type, that is, one in whose hierarchy there are no set-theoretic operators."
msgid "ÐÑо обÑединение Ñипов."
msgstr "This is a union of types."
msgid "ÐÑо пеÑеÑеÑение Ñипов."
msgstr "This is the intersection of types."
msgid "ÐÑо иÑклÑÑение Ñипа."
msgstr "This is a type exception."
msgid "ÐÑо пеÑеÑиÑление."
msgstr "This is an enumeration."
msgid "ÐÑо инÑеÑвалÑнÑй Ñип."
msgstr "This is an interval type."
i18n/Aion/Type.ru-en.po view on Meta::CPAN
msgid "ТеÑÑиÑÑÐµÑ `$_`."
msgstr "Tests `$_`."
msgid "СÑÑингиÑиÑиÑÑÐµÑ Ð¾Ð±ÑекÑ."
msgstr "Strings an object."
msgid "Ðли. Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð½Ð¾Ð²Ñй Ñип как обÑединение двÑÑ
."
msgstr "Or. Creates a new type as a union of two."
msgid "Ð. Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð½Ð¾Ð²Ñй Ñип как пеÑеÑеÑение двÑÑ
."
msgstr "I. Creates a new type as the intersection of two."
msgid "Ðе. Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð½Ð¾Ð²Ñй Ñип как иÑклÑÑение данного."
msgstr "Not. Creates a new type as an exception to the given one."
msgid "ТеÑÑиÑÑÐµÑ Ð·Ð½Ð°Ñение."
msgstr "Tests the value."
msgid "ÐÑиведение к ÑипÑ."
msgstr "Casting to type."
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "СоздаÑÑ Ð½Ð¾Ð²Ñй Ñип."
msgstr "Creates a new type."
msgid "`where` и `message` â ÑÑо ÑинÑакÑиÑеÑкий ÑаÑ
аÑ, а `subtype` можно иÑполÑзоваÑÑ Ð±ÐµÐ· ниÑ
."
msgstr "`where` and `message` are syntactic sugar, and `subtype` can be used without them."
msgid "ÐÑполÑзÑеÑÑÑ Ñ `subtype` Ð´Ð»Ñ ÑаÑÑиÑÐµÐ½Ð¸Ñ Ñоздаваемого Ñипа `$super_type`."
msgstr "Used with `subtype` to extend the created `$super_type` type."
msgid "`as` Ð¼Ð¾Ð¶ÐµÑ Ð¿ÑинимаÑÑ Ð²ÑÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð¸Ð· Ñипов обÑединÑннÑе множеÑÑвенно-ÑеоÑиÑиÑеÑкими опеÑаÑоÑами. Так же в нÑм допÑÑкаÑÑÑÑ Ð¿Ð°ÑамеÑÑÑ `A`, `...
msgstr "`as` can accept type expressions combined with set-theoretic operators. It also allows the parameters `A`, `B`, `C`, `D`, `ARGS`, `SELF`, `M` and `N`. `M` and `N` can be set in the `init_where` section of the parameterized types included in `...
msgid "ÐниÑиализиÑÑÐµÑ Ñип Ñ Ð½Ð¾Ð²Ñми аÑгÑменÑами. ÐÑполÑзÑеÑÑÑ Ñ `subtype`."
msgstr "Initializes a type with new arguments. Used with `subtype`."
msgid "ÐниÑиализаÑÐ¸Ñ â лениваÑ. ÐÑо знаÑиÑ, ÑÑо она ÑÑабоÑÐ°ÐµÑ Ð² меÑоде `test` или подобном."
msgstr "Initialization is lazy. This means that it will work in the `test` method or similar."
msgid "ÐÑполÑзÑÐµÑ `$code` как ÑеÑÑ. ÐнаÑение Ð´Ð»Ñ ÑеÑÑа пеÑедаÑÑÑÑ Ð² `$_`."
msgstr "Uses `$code` as a test. The value for the test is passed to `$_`."
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "ÐеобÑ
одимо, еÑли аÑгÑменÑÑ Ð½ÐµÐ¾Ð±ÑзаÑелÑнÑ."
msgstr "Required if arguments are optional."
msgid "ТекÑÑий Ñип. `SELF` иÑполÑзÑеÑÑÑ Ð² `init_where`, `where` и `awhere`."
msgstr "Current type. `SELF` is used in `init_where`, `where` and `awhere`."
msgid "ÐÑгÑменÑÑ ÑекÑÑего Ñипа. Ð ÑкалÑÑном конÑекÑÑе возвÑаÑÐ°ÐµÑ ÑÑÑÐ»ÐºÑ Ð½Ð° маÑÑив, а в конÑекÑÑе маÑÑива возвÑаÑÐ°ÐµÑ ÑпиÑок. ÐÑполÑзÑеÑÑÑ Ð² ...
msgstr "Arguments of the current type. In a scalar context, it returns a reference to an array, and in an array context, it returns a list. Used in `init_where`, `where` and `awhere`."
msgid "A, B, C, D â пеÑвÑй, вÑоÑой, ÑÑеÑий и пÑÑÑй аÑгÑÐ¼ÐµÐ½Ñ Ñипа."
msgstr "A, B, C, D â the first, second, third and fifth type argument."
msgid "ÐÑполÑзÑеÑÑÑ Ð² `init_where`, `where` и `awhere`."
msgstr "Used in `init_where`, `where` and `awhere`."
msgid "ÐÑоÑой аÑгÑÐ¼ÐµÐ½Ñ Ñипа."
msgstr "Second type argument."
msgid "ТÑеÑий аÑгÑÐ¼ÐµÐ½Ñ Ñипа."
msgstr "Third type argument."
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "Ðижний Ñип можно полÑÑиÑÑ ÐºÐ°Ðº `~Any`."
msgstr "The bottom type can be obtained as `~Any`."
msgid "Тип веÑÑ
него ÑÑÐ¾Ð²Ð½Ñ Ð² конÑÑÑÑкÑоÑаÑ
иеÑаÑÑ
ии ÑÐ¾Ð·Ð´Ð°ÐµÑ Ð½Ð¾Ð²Ñе ÑÐ¸Ð¿Ñ Ð¸Ð· лÑбÑÑ
Ñипов."
msgstr "The top-level type in hierarchy constructors creates new types from any types."
msgid "СоÑз неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 | $type2`."
msgstr "Union of several types. Similar to the `$type1 | $type2`."
msgid "ÐеÑеÑеÑение неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 & $type2`."
msgstr "The intersection of several types. Similar to the `$type1 & $type2` operator."
msgid "ÐÑклÑÑение знаÑÐµÐ½Ð¸Ñ Ñипа. ÐналогиÑен опеÑаÑоÑÑ `~ $type`."
msgstr "Type value exception. Similar to the `~$type` operator."
msgid "ÐополниÑелÑнÑе клÑÑи в `Dict`."
msgstr "Additional keys in `Dict`."
msgid "ÐÑли подпÑогÑамма возвÑаÑÐ°ÐµÑ ÑазнÑе знаÑÐµÐ½Ð¸Ñ Ð² конÑекÑÑе маÑÑива и ÑкалÑÑа, Ñо иÑполÑзÑеÑÑÑ Ñип `Wantarray` Ñ Ñипом `A` Ð´Ð»Ñ ÐºÐ¾Ð½ÑекÑÑа маÑÑÐ...
msgstr "If the routine returns different values in array and scalar contexts, then the `Wantarray` type is used with type `A` for the array context and type `S` for the scalar context."
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "Ð Ñ Ð½ÐµÐ³Ð¾ пеÑегÑÑÐ¶ÐµÐ½Ñ ÑказаннÑе опеÑаÑоÑÑ."
msgstr "And the specified operators are overloaded."
msgid "ÐлаÑÑ Ð¸Ð»Ð¸ обÑÐµÐºÑ Ð½Ð°ÑледÑÐµÑ ÐºÐ»Ð°ÑÑÑ Ð¸Ð· ÑпиÑка."
msgstr "A class or object inherits classes from a list."
msgid "ÐлаÑÑ Ð¸Ð»Ð¸ обÑÐµÐºÑ Ð¸Ð¼ÐµÐµÑ ÑказаннÑе Ñоли."
msgstr "A class or object has the specified roles."
msgid "ÐÑовеÑÑÐµÑ 1, 0, \"\", undef или обÑÐµÐºÑ Ñ Ð¿ÐµÑегÑÑженнÑм опеÑаÑоÑом `bool` или `0+` как `JSON::PP::Boolean`. Ðо вÑоÑом ÑлÑÑае вÑзÑÐ²Ð°ÐµÑ Ð¾Ð¿ÐµÑаÑÐ¾Ñ `0+` и пÑовеÑÑ...
msgstr "Tests for 1, 0, \"\", undef, or an object with an overloaded `bool` or `0+` operator as `JSON::PP::Boolean`. In the second case, it calls the `0+` operator and checks the result as `Bool`."
msgid "`BoolLike` вÑзÑÐ²Ð°ÐµÑ Ð¾Ð¿ÐµÑаÑÐ¾Ñ `0+` и пÑовеÑÑÐµÑ ÑезÑлÑÑаÑ."
msgstr "`BoolLike` calls the `0+` operator and checks the result."
msgid "СÑÑока или обÑÐµÐºÑ Ñ Ð¿ÐµÑегÑÑженнÑм опеÑаÑоÑом `\"\"`."
msgstr "A string or object overloaded with the `\"\"` operator."
msgid "РегÑлÑÑное вÑÑажение или обÑÐµÐºÑ Ñ Ð¿ÐµÑегÑÑженнÑм опеÑаÑоÑом `qr`."
msgstr "A regular expression or object with an overload of the `qr` operator."
lib/Aion/Type.md view on Meta::CPAN
($Int & $Char)->stringify # => ( Int[3, 5] & Char )
($Int | $Char)->stringify # => ( Int[3, 5] | Char )
(~$Int)->stringify # => ~Int[3, 5]
```
ÐпеÑаÑии â ÑÑо обÑекÑÑ `Aion::Type` Ñо ÑпеÑиалÑнÑми именами:
```perl
Aion::Type->new(name => "Exclude", args => [$Char])->stringify # => ~Char
Aion::Type->new(name => "Union", args => [$Int, $Char])->stringify # => ( Int[3, 5] | Char )
Aion::Type->new(name => "Intersection", args => [$Int, $Char])->stringify # => ( Int[3, 5] & Char )
```
## test
ТеÑÑиÑÑеÑ, ÑÑо `$_` пÑÐ¸Ð½Ð°Ð´Ð»ÐµÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑÑ.
```perl
my $PositiveInt = Aion::Type->new(
name => "PositiveInt",
test => sub { /^\d+$/ },
lib/Aion/Type.md view on Meta::CPAN
Тип ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ.
## differs ($other)
Тип не ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ.
## disjoint ($other)
Тип не Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑений Ñ Ð´ÑÑгим Ñипом.
## intersects ($other)
Тип Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑение или пеÑеÑеÑÐµÐ½Ð¸Ñ Ñ Ð´ÑÑгим Ñипом.
## make ($pkg)
СоздаÑÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ð±ÐµÐ· аÑгÑменÑов, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
```perl
BEGIN {
Aion::Type->new(name=>"Rim", test => sub { /^[IVXLCDM]+$/i })->make(__PACKAGE__);
lib/Aion/Type.md view on Meta::CPAN
## is_union ()
ÐÑо обÑединение Ñипов.
```perl
Aion::Types::Int->is_union # -> ""
(Aion::Types::Int | Aion::Types::Int)->is_union # -> 1
```
## is_intersection ()
ÐÑо пеÑеÑеÑение Ñипов.
```perl
Aion::Types::Int->is_intersection # -> ""
(Aion::Types::Int & Aion::Types::Int)->is_intersection # -> 1
```
## is_exclude ()
ÐÑо иÑклÑÑение Ñипа.
```perl
Aion::Types::Any->is_exclude # -> ""
(~Aion::Types::Any)->is_exclude # -> 1
Aion::Types::None->is_exclude # -> 1
lib/Aion/Type.pm view on Meta::CPAN
sub true {1}
use overload
"fallback" => 1,
"&{}" => sub {
my ($self) = @_;
sub { $self->test }
},
'""' => "stringify",
"|" => sub { Aion::Types::Union([@_[0, 1]]) },
"&" => sub { Aion::Types::Intersection([@_[0, 1]]) },
"~" => sub { Aion::Types::Exclude([shift]) },
"~~" => "include",
">>" => "coerce",
"eq" => "identical",
"ne" => "distinct",
"lt" => sub {die "lt do'nt used!"},
"gt" => sub {die "gt do'nt used!"},
"le" => sub {die "le do'nt used!"},
"ge" => sub {die "ge do'nt used!"},
"cmp" => "compare",
lib/Aion/Type.pm view on Meta::CPAN
#@category strings
# СÑÑоковое пÑедÑÑавление
sub stringify {
my ($self) = @_;
my @args = map Aion::Meta::Util::val_to_str($_), @{$self->{args}};
$self->is_union? join "", "( ", join(" | ", @args), " )":
$self->is_intersection? join "", "( ", join(" & ", @args), " )":
$self->is_exclude? "~$args[0]":
join("", $self->{name}, @args? ("[", join(", ", @args), "]") : ());
}
# СообÑение об оÑибке
sub detail {
(my $self, local $_, my $name) = @_;
local $Aion::Type::SELF = $self;
$self->{message}? do { local $self->{property} = $name; $self->{message}->() }:
"$name must have the type $self. The it is ${\
lib/Aion/Type.pm view on Meta::CPAN
#@category compare
#my $_any; my $_none;
sub Any() { *Any = \&Aion::Types::Any; &Any }
sub None() { *None = \&Aion::Types::None; &None }
# refaddr coerce => минималÑÐ½Ð°Ñ Ð½Ð¸Ð¶Ð½ÑÑ Ð³ÑаниÑа. У Range она -Inf, а Ñ Ð¾ÑÑалÑнÑÑ
â 0
our %range_lbound;
# ÐпÑеделÑеÑ, ÑÑо Ñип â множеÑÑвенно-ÑеоÑеÑиÑеÑкий опеÑаÑоÑ
my $set_theoretic = [qw/Union Intersection Exclude/];
sub is_set_theoretic { shift->{name} ~~ $set_theoretic }
sub is_union { shift->{name} eq 'Union' }
sub is_intersection { shift->{name} eq 'Intersection' }
sub is_exclude { shift->{name} eq 'Exclude' }
sub is_enum { shift->{name} eq 'Enum' }
sub is_range_type { exists $range_lbound{Scalar::Util::refaddr shift->{coerce}} }
sub range_lbound { $range_lbound{Scalar::Util::refaddr shift->{coerce}} }
sub is_range { shift->range_lbound == '-Inf' }
# ФоÑмиÑÑÐµÑ ÐºÐ»ÑÑ Ñ Ð¾ÑÑоÑÑиÑованнÑми ÑипизиÑованнÑми паÑамеÑÑами
sub typed_sorted_args_key {
my ($self) = @_;
my $coerceaddr = Scalar::Util::refaddr $self->{coerce};
lib/Aion/Type.pm view on Meta::CPAN
}
# A поÑомок B
sub instanceof {
my ($self, $name) = @_;
my @S = $self;
while(@S) {
my $x = pop @S;
return 1 if $x->{name} eq $name;
if($x->is_intersection) { push @S, @{$x->{args}} }
elsif($x->is_set_theoretic) {}
else { push @S, $x->{as} if $x->{as} }
}
""
}
# A поÑомок B
sub is_descendant {
my ($self, $other, $is_strict) = @_;
return 1 if $is_strict && $self eq $other
|| !$is_strict && $self->like($other);
if ($self->is_intersection) {
return List::Util::any { $_->is_descendant($other, $is_strict) } @{$self->{args}};
}
if ($self->is_union) {
return List::Util::all { $_->is_descendant($other, $is_strict) } @{$self->{args}};
}
if ($self->is_exclude) {
return $self->{args}[0]->is_descendant($other->is_exclude? $other->{args}[0]: ~$other, $is_strict);
}
return $self->{as}->is_descendant($other, $is_strict) if $self->{as};
""
}
# СÑÐ°Ð²Ð½Ð¸Ð²Ð°ÐµÑ Ð¿Ð¾ пÑоÑоÑипам
sub like {
my ($self, $other) = @_;
return List::Util::all { $_->[0]->like($_->[1]) } List::Util::zip $self->{args}, $other->{args} if $self->is_intersection && $other->is_intersection;
return List::Util::any { $_->[0]->like($_->[1]) } List::Util::zip $self->{args}, $other->{args} if $self->is_union && $other->is_union;
return $self->{args}[0]->like($other->{args}[0]) if $self->is_exclude && $other->is_exclude;
return "" if $self->is_set_theoretic || $other->is_set_theoretic;
$self->{coerce} == $other->{coerce};
}
# ТождеÑÑво
sub identical {
my ($self, $other) = @_;
lib/Aion/Type.pm view on Meta::CPAN
sub _unfolding {
my ($self) = @_;
my @u;
for(my $i=$self; $i; $i = $i->{as}) {
unshift(@u, $i->clone(args => [map $_->_unfolding, @{$i->{args}}])), last if $i->is_set_theoretic;
unshift @u, $i if $i->{test} != \&true;
}
@u == 0? Any:
@u == 1? $u[0]: Aion::Types::Intersection(\@u);
}
# ÐÑоÑалкивание иÑклÑÑений к ÑеÑмам, заодно ÑменÑÑÐ°ÐµÑ ÑазмеÑноÑÑÑ Ñ Ð¿Ñиведением
sub _pushing {
my ($self) = @_;
if($self->is_exclude) {
my $inner = $self->{args}[0];
# ~(~A) => A
return $inner->{args}[0]->_pushing if $inner->is_exclude;
# ~(A | B) => ~A & ~B
return _intersection(map { (~$_)->_pushing } @{$inner->{args}}) if $inner->is_union;
# ~(A & B) => ~A | ~B
return _union(map { (~$_)->_pushing } @{$inner->{args}}) if $inner->is_intersection;
# Range[A, B] => Range[-Inf, Invert[A]] | Range[Invert[B], Inf]
if($inner->is_range_type) {
my ($min, $max) = @{$inner->{args}};
if($inner->is_range) {
return None if $min == '-Inf' && $max == 'Inf';
return $inner->clone(args => [Aion::Type::Lim->from($max)->inc, 'Inf']) if $min == '-Inf';
return $inner->clone(args => ['-Inf', Aion::Type::Lim->from($min)->dec]) if $max == 'Inf';
return $inner->clone(args => ['-Inf', Aion::Type::Lim->from($min)->dec]) | $inner->clone(args => [Aion::Type::Lim->from($max)->inc, 'Inf']);
}
return None if $min == 0 && $max == 'Inf';
return $inner->clone(args => [$max+1, 'Inf']) if $min == 0;
return $inner->clone(args => [0, $min-1]) if $max == 'Inf';
return $inner->clone(args => [0, $min-1]) | $inner->clone(args => [$max+1, 'Inf']);
}
return $self;
}
return _intersection(map $_->_pushing, @{$self->{args}}) if $self->is_intersection;
return _union(map $_->_pushing, @{$self->{args}}) if $self->is_union;
$self
}
# Ð¡Ð¶Ð¸Ð¼Ð°ÐµÑ Ð² ÐÐФ
sub _distribute {
my ($self) = @_;
# (A|B) & (C|D|E) & F => (A&C&F) | (A&D&F) | (A&E&F) | (B&C&F) | (B&D&F) | (B&E&F)
if($self->is_intersection) {
my @disjuncts = map { my $x = $_->_distribute; $x->is_union? [@{$x->{args}}]: [$x] } @{$self->{args}};
my $dnf = List::Util::reduce {
[ map { my $p = $_; map { [@$p, $_] } @$b } @$a ]
} [[]], @disjuncts;
return _union(map _intersection(@$_), @$dnf);
}
return _union(map $_->_distribute, @{$self->{args}}) if $self->is_union;
$self
}
# ÐбÑединение инÑеÑвалов
sub _union_ranges {
my ($ranges) = @_;
lib/Aion/Type.pm view on Meta::CPAN
if(@ranges == 1) {
my ($min, $max) = @{$range->{args}};
return Any if $min == $range->range_lbound && $max == 'Inf';
}
@ranges
}
# ÐбÑабаÑÑÐ²Ð°ÐµÑ Ð¿ÐµÑеÑеÑение гÑÐ°Ð½Ð¸Ñ Ð¾Ð´Ð½Ð¾ÑипнÑÑ
диапазонов
sub _intersection_ranges($) {
my ($ranges) = @_;
# ÐÑÑÑой диапазон - ÑÑо None
return None if 0 == grep $_->{args}[0] <= $_->{args}[1], @$ranges;
# СоÑÑиÑÑем в поÑÑдке возÑаÑÑÐ°Ð½Ð¸Ñ Ð½Ð¸Ð¶Ð½ÐµÐ¹ гÑаниÑÑ
my ($range, @ranges) = sort { $a->{args}[0] <=> $b->{args}[0] } @$ranges;
for my $arange (@ranges) {
# ÐÑли Ñ
оÑÑ Ð±Ñ Ñ Ð¾Ð´Ð½Ð¾Ð³Ð¾ Ð½ÐµÑ Ð¿ÐµÑеÑеÑений â ÑÑо None
lib/Aion/Type.pm view on Meta::CPAN
}
delete @exclude_enum{keys %enum};
return Any unless keys %exclude_enum;
~$first_exclude_enum->clone(args => [sort values %exclude_enum])->init;
}
# ÐеÑеÑеÑение пеÑеÑиÑлений
sub _intersection_enums($,$) {
my ($enums, $exclude_enums) = @_;
my %exclude_enum = map {($_=>$_)} map @{$_->{args}}, @$exclude_enums;
return ~$exclude_enums->[0]->clone(args => [sort values %exclude_enum])->init unless @$enums;
my $first_enum = shift(@$enums);
my %enum = map {($_=>$_)} @{$first_enum->{args}};
for my $enum (@$enums) {
delete @enum{grep { !($_ ~~ $enum->{args}) } keys %enum};
lib/Aion/Type.pm view on Meta::CPAN
if(exists $range_lbound{$addr}) { push @{$bag{$addr}}, $candidate }
elsif($candidate->is_enum) { push @enums, $candidate }
elsif($candidate->is_exclude && $candidate->{args}[0]->is_enum) { push @exclude_enums, $candidate->{args}[0] }
else { push @any, $candidate }
}
return @any, @enums || @exclude_enums? $enums_fn->(\@enums, \@exclude_enums): (), map $ranges_fn->($_), values %bag;
}
# Создание пеÑеÑеÑÐµÐ½Ð¸Ñ Ñ Ð¿Ñиведением
sub _intersection(@) {
my %x = map {($_->key => $_)} _ranges_bag \&_intersection_ranges, \&_intersection_enums, map { $_->is_intersection? @{$_->{args}}: $_ } @_;
# ~Any & A = ~Any
return None if exists $x{None->key};
# Any & A = A
delete $x{Any->key};
# Intersection[A] = A
return (values %x)[0] if 1 == keys %x;
# Intersection[] = Any
return Any if 0 == keys %x;
# A & ~A = ~Any
return None if List::Util::first { $_->is_exclude && exists $x{$_->{args}[0]->key} } values %x;
Aion::Types::Intersection([values %x]);
}
# Создание обÑÐµÐ´Ð¸Ð½ÐµÐ½Ð¸Ñ Ñ Ð¿Ñиведением
sub _union(@) {
my %x = map {($_->key => $_)} _ranges_bag \&_union_ranges, \&_union_enums, map { $_->is_union? @{$_->{args}}: $_ } @_;
# Any | A = Any
return Any if exists $x{Any->key};
# ~Any | A = A
delete $x{None->key};
# Union[A] = A
lib/Aion/Type.pm view on Meta::CPAN
Operations are also converted to a string:
($Int & $Char)->stringify # => ( Int[3, 5] & Char )
($Int | $Char)->stringify # => ( Int[3, 5] | Char )
(~$Int)->stringify # => ~Int[3, 5]
Operations are C<Aion::Type> objects with special names:
Aion::Type->new(name => "Exclude", args => [$Char])->stringify # => ~Char
Aion::Type->new(name => "Union", args => [$Int, $Char])->stringify # => ( Int[3, 5] | Char )
Aion::Type->new(name => "Intersection", args => [$Int, $Char])->stringify # => ( Int[3, 5] & Char )
=head2 test
Tests that C<$_> belongs to a class.
my $PositiveInt = Aion::Type->new(
name => "PositiveInt",
test => sub { /^\d+$/ },
);
lib/Aion/Type.pm view on Meta::CPAN
A type is equivalent to another type.
=head2 differs ($other)
A type is not equivalent to another type.
=head2 disjoint ($other)
A type has no overlap with another type.
=head2 intersects ($other)
A type has an intersection or intersections with another type.
=head2 make ($pkg)
Creates a subroutine with no arguments that returns a type.
BEGIN {
Aion::Type->new(name=>"Rim", test => sub { /^[IVXLCDM]+$/i })->make(__PACKAGE__);
}
"IX" ~~ Rim # => 1
lib/Aion/Type.pm view on Meta::CPAN
Aion::Types::Int->is_primitive # -> 1
Aion::Types::Like->is_primitive # -> ""
=head2 is_union ()
This is a union of types.
Aion::Types::Int->is_union # -> ""
(Aion::Types::Int | Aion::Types::Int)->is_union # -> 1
=head2 is_intersection ()
This is the intersection of types.
Aion::Types::Int->is_intersection # -> ""
(Aion::Types::Int & Aion::Types::Int)->is_intersection # -> 1
=head2 is_exclude ()
This is a type exception.
Aion::Types::Any->is_exclude # -> ""
(~Aion::Types::Any)->is_exclude # -> 1
Aion::Types::None->is_exclude # -> 1
~Aion::Types::Any eq Aion::Types::None # -> 1
lib/Aion/Type.pm view on Meta::CPAN
my $Char = Aion::Type->new(name => "Char", test => sub { /^.\z/ });
my $IntOrChar = $Int | $Char;
77 ~~ $IntOrChar # -> 1
"a" ~~ $IntOrChar # -> 1
"ab" ~~ $IntOrChar # -> ""
=head2 &
I. Creates a new type as the intersection of two.
my $Int = Aion::Type->new(name => "Int", test => sub { /^-?\d+$/ });
my $Char = Aion::Type->new(name => "Char", test => sub { /^.\z/ });
my $Digit = $Int & $Char;
7 ~~ $Digit # -> 1
77 ~~ $Digit # -> ""
"a" ~~ $Digit # -> ""
lib/Aion/Types.md view on Meta::CPAN
* `subtype`, `as`, `init_where`, `where`, `awhere`, `message` â Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð²Ð°Ð»Ð¸Ð´Ð°ÑоÑов.
* `SELF`, `ARGS`, `A`, `B`, `C`, `D`, `M`, `N` â Ð´Ð»Ñ Ð¸ÑполÑÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð² валидаÑоÑаÑ
Ñипа и его аÑгÑменÑов.
* `coerce`, `from`, `via` â Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÐºÐ¾Ð½Ð²ÐµÑÑоÑа знаÑений из одного клаÑÑа в дÑÑгой.
ÐеÑаÑÑ
Ð¸Ñ Ð²Ð°Ð»Ð¸Ð´Ð°ÑоÑов:
```text
Any
Control
Union[A, B...]
Intersection[A, B...]
Exclude[A...]
Option[A]
Wantarray[A, B]
Item
External[type]
Bool
BoolLike
Enum[e...]
Maybe[A]
Undef
lib/Aion/Types.md view on Meta::CPAN
## Union[A, B...]
СоÑз неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 | $type2`.
```perl
33 ~~ Union[Int, Ref] # -> 1
[] ~~ Union[Int, Ref] # -> 1
"a" ~~ Union[Int, Ref] # -> ""
```
## Intersection[A, B...]
ÐеÑеÑеÑение неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 & $type2`.
```perl
15 ~~ Intersection[Int, StrMatch[/5/]] # -> 1
```
## Exclude[A]
ÐÑклÑÑение знаÑÐµÐ½Ð¸Ñ Ñипа. ÐналогиÑен опеÑаÑоÑÑ `~ $type`.
```perl
-5 ~~ Exclude[PositiveInt] # -> 1
"a" ~~ Exclude[PositiveInt] # -> 1
5 ~~ Exclude[PositiveInt] # -> ""
lib/Aion/Types.pm view on Meta::CPAN
constant->import(_8BITS => $_8bits);
$_8bits
}
BEGIN {
subtype "Any";
subtype "Control", as &Any;
subtype "Union[A, B...]", as &Control,
where { my $val = $_; any { $_->include($val) } ARGS };
subtype "Intersection[A, B...]", as &Control,
where { my $val = $_; all { $_->include($val) } ARGS };
subtype "Exclude[A]", as &Control,
where { !A->test };
subtype "Option[A]", as &Control,
init_where { SELF->{is_option} = 1 }
where { A->test };
subtype "Wantarray[A, S]", as &Control,
init_where { SELF->{is_wantarray} = 1 }
where { ... };
lib/Aion/Types.pm view on Meta::CPAN
coerce &Rat => from &StrRat => via { Math::BigRat->new($_) };
subtype "PositiveNum", as &Num & Range([0, 'Inf']);
subtype "PositiveInt", as &Int & Range([0, 'Inf']);
subtype "Nat", as &Int & Range([1, 'Inf']);
my $_none = ~&Any;
sub None() { $_none }
};
$_->keyfn(\&Aion::Type::typed_sorted_args_key) for Union[], Intersection[];
(Enum[])->keyfn(\&Aion::Type::sorted_args_key);
%Aion::Type::range_lbound = map { (Scalar::Util::refaddr $_->{coerce} => $_->{name} eq 'Range'? '-Inf': 0) } Range[], Lim[], LimKeys[], Len[];
1;
__END__
=encoding utf-8
lib/Aion/Types.pm view on Meta::CPAN
=item * C<coerce>, C<from>, C<via> - to create a value converter from one class to another.
=back
Validator hierarchy:
Any
Control
Union[A, B...]
Intersection[A, B...]
Exclude[A...]
Option[A]
Wantarray[A, B]
Item
External[type]
Bool
BoolLike
Enum[e...]
Maybe[A]
Undef
lib/Aion/Types.pm view on Meta::CPAN
2 ~~ Many # -> 1
eval { subtype Many => (where1 => sub { $_ > 1 }) }; $@ # ~> subtype Many unused keys left: where1
eval { subtype 'Many' }; $@ # ~> subtype Many: main::Many exists!
=head2 as ($super_type)
Used with C<subtype> to extend the created C<$super_type> type.
C<as> can accept type expressions combined with set-theoretic operators. It also allows the parameters C<A>, C<B>, C<C>, C<D>, C<ARGS>, C<SELF>, C<M> and C<N>. C<M> and C<N> can be set in the C<init_where> section of the parameterized types included ...
BEGIN {
subtype 'Top[to]', as Range[0, A];
}
+3.0 ~~ Top[3] # -> 1
+3.1 ~~ Top[3] # -> ""
+0.0 ~~ Top[3] # -> 1
-0.1 ~~ Top[3] # -> ""
lib/Aion/Types.pm view on Meta::CPAN
=head2 SELF
Current type. C<SELF> is used in C<init_where>, C<where> and C<awhere>.
=head2 ARGS
Arguments of the current type. In a scalar context, it returns a reference to an array, and in an array context, it returns a list. Used in C<init_where>, C<where> and C<awhere>.
=head2 A
A, B, C, D â the first, second, third and fifth type argument.
BEGIN {
subtype "Seria[a,b,c,d]", where { A < B && B < $_ && $_ < C && C < D };
}
2.5 ~~ Seria[1,2,3,4] # -> 1
Used in C<init_where>, C<where> and C<awhere>.
=head1 B
lib/Aion/Types.pm view on Meta::CPAN
The top-level type in hierarchy constructors creates new types from any types.
=head2 Union[A, B...]
Union of several types. Similar to the C<$type1 | $type2>.
33 ~~ Union[Int, Ref] # -> 1
[] ~~ Union[Int, Ref] # -> 1
"a" ~~ Union[Int, Ref] # -> ""
=head2 Intersection[A, B...]
The intersection of several types. Similar to the C<$type1 & $type2> operator.
15 ~~ Intersection[Int, StrMatch[/5/]] # -> 1
=head2 Exclude[A]
Type value exception. Similar to the C<~$type> operator.
-5 ~~ Exclude[PositiveInt] # -> 1
"a" ~~ Exclude[PositiveInt] # -> 1
5 ~~ Exclude[PositiveInt] # -> ""
5.5 ~~ Exclude[PositiveInt] # -> 1
lib/Aion/Types.pm view on Meta::CPAN
package RoleExample { sub DOES { $_[1] ~~ [qw/Role1 Role2/] } }
'RoleExample' ~~ ConsumerOf[qw/Role1/] # -> 1
'RoleExample' ~~ ConsumerOf[qw/Role2 Role1/] # -> 1
bless({}, 'RoleExample') ~~ ConsumerOf[qw/Role3 Role2 Role1/] # -> ""
'NoneExample' ~~ ConsumerOf[qw/Role1/] # -> ""
=head2 BoolLike
Tests for 1, 0, "", undef, or an object with an overloaded C<bool> or C<0+> operator as C<JSON::PP::Boolean>. In the second case, it calls the C<0+> operator and checks the result as C<Bool>.
C<BoolLike> calls the C<0+> operator and checks the result.
package BoolLikeExample {
use overload '0+' => sub { ${$_[0]} };
}
bless(\(my $x = 1 ), 'BoolLikeExample') ~~ BoolLike # -> 1
bless(\(my $x = 11), 'BoolLikeExample') ~~ BoolLike # -> ""
t/aion/type.t view on Meta::CPAN
local ($::_g0 = do {($Int & $Char)->stringify}, $::_e0 = "( Int[3, 5] & Char )"); ::ok $::_g0 eq $::_e0, '($Int & $Char)->stringify # => ( Int[3, 5] & Char )' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {($Int | $Char)->stringify}, $::_e0 = "( Int[3, 5] | Char )"); ::ok $::_g0 eq $::_e0, '($Int | $Char)->stringify # => ( Int[3, 5] | Char )' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {(~$Int)->stringify}, $::_e0 = "~Int[3, 5]"); ::ok $::_g0 eq $::_e0, '(~$Int)->stringify # => ~Int[3, 5]' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ÐпеÑаÑии â ÑÑо обÑекÑÑ `Aion::Type` Ñо ÑпеÑиалÑнÑми именами:
#
local ($::_g0 = do {Aion::Type->new(name => "Exclude", args => [$Char])->stringify}, $::_e0 = "~Char"); ::ok $::_g0 eq $::_e0, 'Aion::Type->new(name => "Exclude", args => [$Char])->stringify # => ~Char' or ::diag ::_string_diff($::_g0, $::_e0); und...
local ($::_g0 = do {Aion::Type->new(name => "Union", args => [$Int, $Char])->stringify}, $::_e0 = "( Int[3, 5] | Char )"); ::ok $::_g0 eq $::_e0, 'Aion::Type->new(name => "Union", args => [$Int, $Char])->stringify # => ( Int[3, 5] | Char )' or ::di...
local ($::_g0 = do {Aion::Type->new(name => "Intersection", args => [$Int, $Char])->stringify}, $::_e0 = "( Int[3, 5] & Char )"); ::ok $::_g0 eq $::_e0, 'Aion::Type->new(name => "Intersection", args => [$Int, $Char])->stringify # => ( Int[3, 5] & C...
#
# ## test
#
# ТеÑÑиÑÑеÑ, ÑÑо `$_` пÑÐ¸Ð½Ð°Ð´Ð»ÐµÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑÑ.
#
::done_testing; }; subtest 'test' => sub {
my $PositiveInt = Aion::Type->new(
name => "PositiveInt",
test => sub { /^\d+$/ },
t/aion/type.t view on Meta::CPAN
# Тип ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ.
#
# ## differs ($other)
#
# Тип не ÑквиваленÑен дÑÑÐ³Ð¾Ð¼Ñ ÑипÑ.
#
# ## disjoint ($other)
#
# Тип не Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑений Ñ Ð´ÑÑгим Ñипом.
#
# ## intersects ($other)
#
# Тип Ð¸Ð¼ÐµÐµÑ Ð¿ÐµÑеÑеÑение или пеÑеÑеÑÐµÐ½Ð¸Ñ Ñ Ð´ÑÑгим Ñипом.
#
# ## make ($pkg)
#
# СоздаÑÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ð±ÐµÐ· аÑгÑменÑов, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
#
::done_testing; }; subtest 'make ($pkg)' => sub {
BEGIN {
Aion::Type->new(name=>"Rim", test => sub { /^[IVXLCDM]+$/i })->make(__PACKAGE__);
t/aion/type.t view on Meta::CPAN
#
# ## is_union ()
#
# ÐÑо обÑединение Ñипов.
#
::done_testing; }; subtest 'is_union ()' => sub {
local ($::_g0 = do {Aion::Types::Int->is_union}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'Aion::Types::Int->is_union # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {(Aion::Types::Int | Aion::Types::Int)->is_union}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '(Aion::Types::Int | Aion::Types::Int)->is_union # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); u...
#
# ## is_intersection ()
#
# ÐÑо пеÑеÑеÑение Ñипов.
#
::done_testing; }; subtest 'is_intersection ()' => sub {
local ($::_g0 = do {Aion::Types::Int->is_intersection}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'Aion::Types::Int->is_intersection # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {(Aion::Types::Int & Aion::Types::Int)->is_intersection}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '(Aion::Types::Int & Aion::Types::Int)->is_intersection # -> 1' or ::diag ::_struct_diff($::_...
#
# ## is_exclude ()
#
# ÐÑо иÑклÑÑение Ñипа.
#
::done_testing; }; subtest 'is_exclude ()' => sub {
local ($::_g0 = do {Aion::Types::Any->is_exclude}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'Aion::Types::Any->is_exclude # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {(~Aion::Types::Any)->is_exclude}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '(~Aion::Types::Any)->is_exclude # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {Aion::Types::None->is_exclude}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'Aion::Types::None->is_exclude # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
t/aion/types.t view on Meta::CPAN
# * `subtype`, `as`, `init_where`, `where`, `awhere`, `message` â Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð²Ð°Ð»Ð¸Ð´Ð°ÑоÑов.
# * `SELF`, `ARGS`, `A`, `B`, `C`, `D`, `M`, `N` â Ð´Ð»Ñ Ð¸ÑполÑÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð² валидаÑоÑаÑ
Ñипа и его аÑгÑменÑов.
# * `coerce`, `from`, `via` â Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÐºÐ¾Ð½Ð²ÐµÑÑоÑа знаÑений из одного клаÑÑа в дÑÑгой.
#
# ÐеÑаÑÑ
Ð¸Ñ Ð²Ð°Ð»Ð¸Ð´Ð°ÑоÑов:
#
# Any
# Control
# Union[A, B...]
# Intersection[A, B...]
# Exclude[A...]
# Option[A]
# Wantarray[A, B]
# Item
# External[type]
# Bool
# BoolLike
# Enum[e...]
# Maybe[A]
# Undef
t/aion/types.t view on Meta::CPAN
# ## Union[A, B...]
#
# СоÑз неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 | $type2`.
#
::done_testing; }; subtest 'Union[A, B...]' => sub {
local ($::_g0 = do {33 ~~ Union[Int, Ref]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '33 ~~ Union[Int, Ref] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[] ~~ Union[Int, Ref]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '[] ~~ Union[Int, Ref] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {"a" ~~ Union[Int, Ref]}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"a" ~~ Union[Int, Ref] # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## Intersection[A, B...]
#
# ÐеÑеÑеÑение неÑколÑкиÑ
Ñипов. ÐналогиÑен опеÑаÑоÑÑ `$type1 & $type2`.
#
::done_testing; }; subtest 'Intersection[A, B...]' => sub {
local ($::_g0 = do {15 ~~ Intersection[Int, StrMatch[/5/]]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '15 ~~ Intersection[Int, StrMatch[/5/]] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef ...
#
# ## Exclude[A]
#
# ÐÑклÑÑение знаÑÐµÐ½Ð¸Ñ Ñипа. ÐналогиÑен опеÑаÑоÑÑ `~ $type`.
#
::done_testing; }; subtest 'Exclude[A]' => sub {
local ($::_g0 = do {-5 ~~ Exclude[PositiveInt]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '-5 ~~ Exclude[PositiveInt] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {"a" ~~ Exclude[PositiveInt]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"a" ~~ Exclude[PositiveInt] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {5 ~~ Exclude[PositiveInt]}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '5 ~~ Exclude[PositiveInt] # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;