Types::TypeTiny(3) User Contributed Perl Documentation Types::TypeTiny(3)

# [NAME](#NAME)

Types::TypeTiny - type constraints used internally by Type::Tiny

# [STATUS](#STATUS)

This module is covered by the Type-Tiny stability policy.

The **BoolLike** type is currently unstable.

# [DESCRIPTION](#DESCRIPTION)

Dogfooding.

This isn't a real Type::Library-based type library; that would involve too much circularity. But it exports some type constraints which, while designed for use within Type::Tiny, may be more generally useful.

## [Types](#Types)

- **StringLike**
  
  Accepts strings and objects overloading stringification.
- **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.
- **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.
- **\_ForeignTypeConstraint**
  
  Any reference which to\_TypeTiny recognizes as something that can be coerced to a Type::Tiny object.
  
  Yes, the underscore is included.

## [Coercion Functions](#Coercion_Functions)

[to\_TypeTiny($constraint)](#to_TypeTiny%28$constraint%29)

Promotes (or "demotes" if you prefer) a "foreign" type constraint to a Type::Tiny object. 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](#Methods)

These are implemented so that "Types::TypeTiny-&gt;meta-&gt;get\_type($foo)" works, for rough compatibility with a real Type::Library type library.

"meta"

"type\_names"

[get\_type($name)](#get_type%28$name%29)

[has\_type($name)](#has_type%28$name%29)

"coercion\_names"

[get\_coercion($name)](#get_coercion%28$name%29)

[has\_coercion($name)](#has_coercion%28$name%29)

# [BUGS](#BUGS)

Please report any bugs to &lt;https://github.com/tobyink/p5-type-tiny/issues&gt;.

# [SEE ALSO](#SEE_ALSO)

Type::Tiny.

# [AUTHOR](#AUTHOR)

Toby Inkster &lt;tobyink@cpan.org&gt;.

# [COPYRIGHT AND LICENCE](#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.

# [DISCLAIMER OF WARRANTIES](#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.

2026-10-25 perl v5.44.0

---

Document: Types::TypeTiny(3pm) from perl-type-tiny 2.010001-r4 (Chainguard OS)
Source: https://github.com/tobyink/p5-type-tiny
