Types::TypeTiny

Status

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

The BoolLike type is currently unstable.

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

Coercion Functions

to_TypeTiny($constraint)

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

These are implemented so that Types::TypeTiny->meta->get_type($foo) works, for rough compatibility with a real Type::Library type library.

meta
type_names
get_type($name)
has_type($name)
coercion_names
get_coercion($name)
has_coercion($name)

See Also

Type::Tiny .