=pod

=encoding utf-8

=head1 NAME

Type::Tiny::Manual - an overview of Type::Tiny

=head1 SYNOPSIS

L<Type::Tiny> is a small class for writing type constraints, inspired by
L<Moose>'s type constraint API. It has only one non-core dependency (and even
that is simply a module that was previously distributed as part of Type::Tiny
but has since been spun off), and can be used with L<Moose>, L<Mouse> and
L<Moo> (or none of the above).

Type::Tiny is bundled with L<Type::Library> a framework for organizing type
constraints into collections.

Also bundled is L<Types::Standard>, a Moose-inspired library of useful type
constraints.

L<Type::Params> is also provided, to allow very fast checking and coercion
of function and method parameters.

=head1 SEE ALSO

=over

=item *

L<Libraries|Type::Tiny::Manual::Libraries> - how to build a type library with Type::Tiny, Type::Library and Type::Utils

=item *

L<Coercions|Type::Tiny::Manual::Coercions> - adding coercions to type constraints

=item *

L<Using with Moose|Type::Tiny::Manual::UsingWithMoose> - how to use Type::Tiny and Type::Library with Moose

=item *

L<Using with Mouse|Type::Tiny::Manual::UsingWithMouse> - how to use Type::Tiny and Type::Library with Mouse

=item *

L<Using with Moo|Type::Tiny::Manual::UsingWithMoo> - how to use Type::Tiny and Type::Library with Moo

=item *

L<Using with Other OO Frameworks|Type::Tiny::Manual::UsingWithOther> - how to use Type::Tiny and Type::Library with other OO frameworks

=item *

Type::Tiny and friends don't need to be used within an OO framework. See L<FreeMind::Node> for an example that does not.

=item *

L<Processing arguments to subs|Type::Tiny::Manual::Params> - coerce and validate arguments to functions and methods.

=item *

Other modules using Type::Tiny in interesting ways: L<Type::Tie>, L<Test::Mocha>, L<Scalar::Does>, L<Set::Equivalence>...

=item *

L<Optimization|Type::Tiny::Manual::Optimization> - squeeze the most out of your CPU.

=item *

L<Type::Tiny maintenance policies|Type::Tiny::Manual::Policies> - the stability policy.

=back

=head1 DEPENDENCIES

Type::Tiny requires at least Perl 5.6.1, though certain Unicode-related
features (e.g. non-ASCII type constraint names) may work better in newer
versions of Perl.

Type::Tiny requires L<Exporter::Tiny>, a module that was previously
bundled in this distribution, but has since been spun off as a separate
distribution. Don't worry - it's quick and easy to install.

At run-time, Type::Tiny also requires the following modules: L<B>,
L<B::Deparse>, L<Carp>, L<Data::Dumper>, L<Scalar::Util>, L<Text::Balanced>,
L<overload>, L<strict> and L<warnings>. All of these come bundled with
Perl itself. Prior to Perl 5.8, L<Scalar::Util> and L<Text::Balanced>
do not come bundled with Perl and will need installing separately from
the CPAN.

Certain features require additional modules. Tying a variable to a
type constraint (e.g. C<< tie my $count, Int >>) requires L<Type::Tie>;
stack traces on exceptions require L<Devel::StackTrace>. The
L<Reply::Plugin::TypeTiny> plugin for L<Reply> requires L<Reply>
(obviously). L<Devel::LexAlias> may I<slightly> increase the speed
of some of Type::Tiny's compiled coderefs.

L<Type::Tiny::XS> is not required, but if available provides a speed
boost for some type checks. (Setting the environment variable
C<PERL_TYPE_TINY_XS> to false, or setting C<PERL_ONLY> to true will
suppress the use of Type::Tiny::XS, even if it is available.)

The test suite additionally requires L<Test::More>, L<Test::Fatal>
and L<Test::Requires>. Test::More comes bundled with Perl, but if
you are using a version of Perl older than 5.14, you will need to
upgrade to at least Test::More version 0.96. Test::Requires and
Test::Fatal (plus Try::Tiny which Test::Fatal depends on) are bundled
with Type::Tiny in the C<inc> directory, so you do not need to
install them separately.

If using Type::Tiny in conjunction with L<Moo>, then at least Moo
1.000000 is recommended. If using Type::Tiny with L<Moose>, then at
least Moose 2.0000 is recommended. If using Type::Tiny with L<Mouse>,
then at least Mouse 1.00 is recommended. Type::Tiny is mostly
untested against older versions of these packages.

=head1 TYPE::TINY VERSUS X

=head2 Specio 

Type::Tiny is similar in aim to L<Specio>. The major differences are

=over

=item *

Type::Tiny is "tiny" (Specio will eventually have fewer dependencies
than it currently does, but is unlikely to ever have as few as Type::Tiny);

=item *

Specio has a somewhat nicer API (better method names; less duplication),
and its API is likely to improve further. Type::Tiny's aims at complete
compatibility with current versions of Moose and Mouse, so there is a
limit to how much I can deviate from the existing APIs of
(Moose|Mouse)::Meta::TypeConstraint.

=back

=head2 MooseX::Types

Type::Tiny libraries expose a similar interface to L<MooseX::Types> libraries.
In most cases you should be able to rewrite a L<MooseX::Types> library to
use Type::Tiny pretty easily.

=head2 MooX::Types::MooseLike

Type::Tiny is faster and supports coercions.

=head2 Scalar::Does

L<Scalar::Does> is somewhat of a precursor to Type::Tiny, but has now been
rewritten to use Type::Tiny internally.

It gives you a C<< does($value, $type) >> function that is roughly equivalent
to C<< $type->check($value) >> except that C<< $type >> may be one of a list
of pre-defined strings (instead of a Type::Tiny type constraint); or may be
a package name in which case it will be assumed to be a role and checked with
C<< $value->DOES($type) >>.

=head1 BUGS

Please report any bugs to
L<http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny>.

=head1 SUPPORT

B<< IRC: >> support is available through in the I<< #moops >> channel
on L<irc.perl.org|http://www.irc.perl.org/channels.html>.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

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

=head1 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.

=cut
