Types::TypeTiny(3)
π Types::TypeTiny π
okay so bestie, welcome to Types::TypeTiny β the type constraints that Type::Tiny uses internally, like the backstage pass version. it's from the Types::TypeTiny manual page (section 3, perl's own doc set, iykyk) and it's lowkey iconic.
β¨ STATUS β¨
this module is covered by the Type-Tiny stability policy. very official. very protected. π‘οΈ
but heads up: the BoolLike type is currently unstable β it's giving "still cooking", not "ready to serve". π³
πΈ DESCRIPTION πΈ
Dogfooding. πΆπ½οΈ that's it, that's the whole first line, and honestly? respect.
and no, this is not a real Type::Library-based type library β doing that would involve way too much circularity (the snake eating its own tail situation π). but it does export some type constraints which, while they were designed for use within Type::Tiny, may be more generally useful. so like, they were made for one thing but they serve in general too. versatile queens. π
π¦ Types π¦
StringLikeβ accepts strings and objects overloading stringification. if it can stringify, it's in. πBoolLikeβ acceptsundef,"",0,1; accepts any blessed object overloading"bool"; accepts any blessed object overloading"0+"to return0or1. (Needs to actually call the overloaded operation to check that.) Also accepts any object that inherits from"boolean"or reports that as a role ("DOES").
β οΈ Warning: an object which overloads"0+"without also turning on overload fallbacks may actually be useless as a practical boolean. But some common objects such as JSON::PP's booleans overload"0+"instead of overloading"bool"(thankfully with fallbacks enabled!) so we do need to support this.
The intention of this type is to be a version of Bool which also accepts common boolean objects such as JSON::PP::Boolean. It is currently unstable and the exact definition of the type may change to better implement that intended functionality. so like... it might shift on you. π«
HashLike[`a]β accepts hashrefs and objects overloading hashification. ποΈ
Since Types::TypeTiny 1.012, may be parameterized with another type constraint like HashLike[Int].
ArrayLike[`a]β accepts arrayrefs and objects overloading arrayfication. π
Since Types::TypeTiny 1.012, may be parameterized with another type constraint like ArrayLike[Int].
CodeLikeβ accepts coderefs and objects overloading codification. π§βπ»TypeTinyβ accepts blessed Type::Tiny objects. obviously. π_ForeignTypeConstraintβ any reference which to_TypeTiny recognizes as something that can be coerced to a Type::Tiny object.
Yes, the underscore is included. that's part of the name. don't come for her. π
π Coercion Functions π
to_TypeTiny($constraint)
Promotes (or "demotes" if you prefer) a "foreign" type constraint to a Type::Tiny object. she does a whole naturalization ceremony, no cap. Can handle:
- Moose types (including Moose::Meta::TypeConstraint objects and MooseX::Types::TypeDecorator objects).
- Mouse types (including Mouse::Meta::TypeConstraint objects).
- Validation::Class and Validation::Class::Simple objects.
- Types built using Type::Library::Compiler.
- Any object which provides
"check"and"get_message"methods. (This includes Specio and Type::Nano types.) If the object provides"has_coercion"and coerce methods, these will be used to handle quoting. If the object provides"can_be_inlined"and"inline_check"methods, these will be used to handling inlining. If the object provides a"name"method, this will be assumed to return the type name. - Coderefs (but not blessed coderefs or objects overloading
"&{}"unless they provide the methods described above!) Coderefs are expected to return true iff$_passes the constraint. If$_fails the type constraint, they may either return false, or die with a helpful error message. - Sub::Quote-enabled coderefs. These are handled the same way as above, but Type::Tiny will consult Sub::Quote to determine if they can be inlined.
π Methods π
These are implemented so that "Types::TypeTiny->meta->get_type($foo)" works, for rough compatibility with a real Type::Library type library. it's the "fake it till you make it" compatibility layer, and she ate. π₯
"meta""type_names"get_type($name)has_type($name)"coercion_names"get_coercion($name)has_coercion($name)
π BUGS π
Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.
not me asking you to file an issue... but like, do it, bestie. the maintainer is nice. π«Ά
π SEE ALSO π
Type::Tiny. (the main character. this module is her little sibling fr fr.)
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2013-2014, 2017-2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, legally speaking. βοΈβ¨
β DISCLAIMER OF WARRANTIES β
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
translation bestie: no promises, no guarantees, you get what you get and you don't throw a fit. π
and that's the whole page!! πΈ this was the Types::TypeTiny(3) manual page, from perl v5.42.0, dated 2026-01-17 β tysm for reading, go forth and type-constrain responsibly, mwah π
ππ¦
π¦ where this page comes from
- fedora 44: perl-Type-Tiny 2.010001-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms