# Types::TypeTiny - type constraints used internally by Type::Tiny - perldoc - [phpMan]

## NAME
    [Types::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3ATypeTiny/markdown) - type constraints used internally by [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)

## 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](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ALibrary/markdown)-based type library; that would involve too much circularity. But
    it exports some type constraints which, while designed for use within [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown), may be more
    generally useful.

### 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.)

        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](https://www.chedong.com/phpMan.php/perldoc/JSON%3A%3APP/markdown)'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](https://www.chedong.com/phpMan.php/perldoc/JSON%3A%3APP%3A%3ABoolean/markdown). 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](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3ATypeTiny/markdown) 1.012, may be parameterized with another type constraint like
        HashLike[Int].

    *   ArrayLike[`a]

        Accepts arrayrefs and objects overloading arrayfication.

        Since [Types::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3ATypeTiny/markdown) 1.012, may be parameterized with another type constraint like
        ArrayLike[Int].

    *   CodeLike

        Accepts coderefs and objects overloading codification.

    *   TypeTiny

        Accepts blessed [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) objects.

    *   _ForeignTypeConstraint

        Any reference which to_TypeTiny recognizes as something that can be coerced to a [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)
        object.

        Yes, the underscore is included.

### Coercion Functions
### to_TypeTiny
        Promotes (or "demotes" if you prefer) a "foreign" type constraint to a [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) object.
        Can handle:

        *   Moose types (including [Moose::Meta::TypeConstraint](https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3AMeta%3A%3ATypeConstraint/markdown) objects and
            [MooseX::Types::TypeDecorator](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ATypes%3A%3ATypeDecorator/markdown) objects).

        *   Mouse types (including [Mouse::Meta::TypeConstraint](https://www.chedong.com/phpMan.php/perldoc/Mouse%3A%3AMeta%3A%3ATypeConstraint/markdown) objects).

        *   [Validation::Class](https://www.chedong.com/phpMan.php/perldoc/Validation%3A%3AClass/markdown) and [Validation::Class::Simple](https://www.chedong.com/phpMan.php/perldoc/Validation%3A%3AClass%3A%3ASimple/markdown) objects.

        *   Types built using [Type::Library::Compiler](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ALibrary%3A%3ACompiler/markdown).

        *   Any object which provides "check" and "get_message" methods. (This includes Specio and
            [Type::Nano](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ANano/markdown) 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](https://www.chedong.com/phpMan.php/perldoc/Sub%3A%3AQuote/markdown)-enabled coderefs. These are handled the same way as above, but [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)
            will consult [Sub::Quote](https://www.chedong.com/phpMan.php/perldoc/Sub%3A%3AQuote/markdown) to determine if they can be inlined.

### Methods
    These are implemented so that "[Types::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3ATypeTiny/markdown)->meta->get_type($foo)" works, for rough
    compatibility with a real [Type::Library](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ALibrary/markdown) type library.

    "meta"
    "type_names"
### get_type
### has_type
    "coercion_names"
### get_coercion
### has_coercion

## BUGS
    Please report any bugs to <<https://github.com/tobyink/p5-type-tiny/issues>>.

## SEE ALSO
    [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown).

## AUTHOR
    Toby Inkster <<tobyink@cpan.org>>.

## COPYRIGHT AND LICENCE
    This software is copyright (c) 2013-2014, 2017-2023 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
    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.

