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 β€” accepts undef, "", 0, 1; accepts any blessed object overloading "bool"; accepts any blessed object overloading "0+" to return 0 or 1. (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>.


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