# phpman > info > Type::Tiny::Manual

[Type::Tiny::Manual](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual/markdown)(3pmUser Contributed Perl [DocumentatiType::Tiny](https://www.chedong.com/phpMan.php/perldoc/DocumentatiType%3A%3ATiny/markdown)::[Manual(3pm)](https://www.chedong.com/phpMan.php/man/Manual/3pm/markdown)

NAME
       [Type::Tiny::Manual](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual/markdown) - an overview of [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)

SYNOPSIS
       [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) is a small Perl <<http://www.perl.org/>> class for writing
       type constraints, inspired by Moose's type constraint API and
       [MooseX::Types](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ATypes/markdown). It has only one non-core dependency (and even that is
       simply a module that was previously distributed as part of [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)
       but has since been spun off), and can be used with Moose, Mouse, or Moo
       (or none of the above).

       [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) is used by over 800 Perl distributions on the CPAN
       (Comprehensive Perl Archive Network) and can be considered a stable and
       mature framework for efficiently and reliably enforcing data types.

       [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) is bundled with [Type::Library](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ALibrary/markdown) a framework for organizing
       type constraints into collections. Also bundled is [Types::Standard](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3AStandard/markdown), a
       Moose-inspired library of useful type constraints. [Type::Params](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3AParams/markdown) is also
       provided, to allow very fast checking and coercion of function and
       method parameters.

       The following example gives you an idea of some of the features of
       these modules. If you don't understand it all, that's fine; that's what
       the rest of the manual is for. Although the example uses Moo, the "use
       Moo" could be changed to "use Moose" or "use Mouse" and it would still
       work.

        use v5.12;
        use strict;
        use warnings;

        package Horse {
          use Moo;
          use [Types::Standard](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3AStandard/markdown) qw( Str Int Enum ArrayRef InstanceOf );
          use [Type::Params](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3AParams/markdown) qw( compile );
          use [namespace::autoclean](https://www.chedong.com/phpMan.php/perldoc/namespace%3A%3Aautoclean/markdown);

          has name => (
            is       => 'ro',
            isa      => Str,
            required => 1,
          );
          has gender => (
            is       => 'ro',
            isa      => Enum[qw( f m )],
          );
          has age => (
            is       => 'rw',
            isa      => Int->where( '$_ >= 0' ),
          );
          has children => (
            is       => 'ro',
            isa      => ArrayRef[ InstanceOf['Horse'] ],
            default  => sub { return [] },
          );

          sub add_child {
            # method signature
            state $check = compile( InstanceOf['Horse'], InstanceOf['Horse'] );

            my ($self, $child) = $check->(@_);   # unpack @_
            push @{ $self->children }, $child;

            return $self;
          }
        }

        package main;

        my $boldruler = Horse->new(
          name    => "Bold Ruler",
          gender  => 'm',
          age     => 16,
        );

        my $secretariat = Horse->new(
          name    => "Secretariat",
          gender  => 'm',
          age     => 0,
        );

        $boldruler->add_child( $secretariat );

        use [Types::Standard](https://www.chedong.com/phpMan.php/perldoc/Types%3A%3AStandard/markdown) qw( is_Object assert_Object );

        # is_Object will return a boolean
        #
        if ( is_Object($boldruler) ) {
          say $boldruler->name;
        }

        # assert_Object will return $secretariat or die
        #
        say assert_Object($secretariat)->name;

MANUAL
       Even if you are using [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with other object-oriented programming
       toolkits (such as Moose or Mouse), you should start with the Moo
       sections of the manual. Most of the information is directly
       transferrable and the Moose and Mouse sections of the manual list the
       minor differences between using [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with Moo and with them.

       In general, this manual assumes you use Perl 5.12 or above and may use
       examples that do not work on older versions of Perl. [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) does
       work on earlier versions of Perl, but not all the examples and features
       in the manual will run without adjustment. (For instance, you may need
       to replace "state" variables with lexical variables, avoid the "package
       NAME { BLOCK }" syntax, etc.)

       o   [Type::Tiny::Manual::Installation](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AInstallation/markdown)

           How to install [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown). If [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) is already installed, you
           can skip this.

       o   [Type::Tiny::Manual::UsingWithMoo](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithMoo/markdown)

           Basic use of [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with Moo, including attribute type
           constraints, parameterized type constraints, coercions, and method
           parameter checking.

       o   [Type::Tiny::Manual::UsingWithMoo2](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithMoo2/markdown)

           Advanced use of [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with Moo, including unions and
           intersections, "stringifies_to", "numifies_to",
           "with_attribute_values", and "where".

       o   [Type::Tiny::Manual::UsingWithMoo3](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithMoo3/markdown)

           There's more than one way to do it! Alternative ways of using
           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown), including type registries, exported functions, and
           "dwim_type".

       o   [Type::Tiny::Manual::Libraries](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3ALibraries/markdown)

           Defining your own type libraries, including extending existing
           libraries, defining new types, adding coercions, defining
           parameterizable types, and the declarative style.

       o   [Type::Tiny::Manual::UsingWithMoose](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithMoose/markdown)

           How to use [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with Moose, including the advantages of
           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) over built-in type constraints, and Moose-specific
           features.

       o   [Type::Tiny::Manual::UsingWithMouse](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithMouse/markdown)

           How to use [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with Mouse, including the advantages of
           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) over built-in type constraints, and Mouse-specific
           features.

       o   [Type::Tiny::Manual::UsingWithClassTiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithClassTiny/markdown)

           Including how to [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) in your object's "BUILD" method, and
           third-party shims between [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) and [Class::Tiny](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ATiny/markdown).

       o   [Type::Tiny::Manual::UsingWithOther](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithOther/markdown)

           Using [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with [Class::InsideOut](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AInsideOut/markdown), [Params::Check](https://www.chedong.com/phpMan.php/perldoc/Params%3A%3ACheck/markdown), and
           [Object::Accessor](https://www.chedong.com/phpMan.php/perldoc/Object%3A%3AAccessor/markdown).

       o   [Type::Tiny::Manual::UsingWithTestMore](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AUsingWithTestMore/markdown)

           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) for test suites.

       o   [Type::Tiny::Manual::Params](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AParams/markdown)

           Advanced information on [Type::Params](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3AParams/markdown), and using [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) with
           other signature modules like [Function::Parameters](https://www.chedong.com/phpMan.php/perldoc/Function%3A%3AParameters/markdown) and Kavorka.

       o   [Type::Tiny::Manual::NonOO](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3ANonOO/markdown)

           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) in non-object-oriented code.

       o   [Type::Tiny::Manual::Optimization](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AOptimization/markdown)

           Squeeze the most out of your CPU.

       o   [Type::Tiny::Manual::Coercions](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3ACoercions/markdown)

           Advanced information on coercions.

       o   [Type::Tiny::Manual::AllTypes](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AAllTypes/markdown)

           An alphabetical list of all type constraints bundled with
           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown).

       o   [Type::Tiny::Manual::Policies](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3APolicies/markdown)

           Policies related to [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) development.

       o   [Type::Tiny::Manual::Contributing](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual%3A%3AContributing/markdown)

           Contributing to [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) development.

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

SEE ALSO
       The [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) homepage <<https://typetiny.toby.ink/>>.

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

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

perl v5.32.1                      2021-08-31           [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown)::[Manual(3pm)](https://www.chedong.com/phpMan.php/man/Manual/3pm/markdown)
