Type::Tiny::Manual - an overview of Type::Tiny |
Type::Tiny::Manual - an overview of Type::Tiny
the Type::Tiny manpage is a small class for writing type constraints, inspired by 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 Moose, Mouse and Moo (or none of the above).
Type::Tiny is bundled with the Type::Library manpage a framework for organizing type constraints into collections.
Also bundled is the Types::Standard manpage, a Moose-inspired library of useful type constraints.
the Type::Params manpage is also provided, to allow very fast checking and coercion of function and method parameters.
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 the Exporter::Tiny manpage, 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: the B manpage, the B::Deparse manpage, Carp, the Data::Dumper manpage, the Scalar::Util manpage, the Text::Balanced manpage, the overload manpage, the strict manpage and the warnings manpage. All of these come bundled with Perl itself. Prior to Perl 5.8, the Scalar::Util manpage and the Text::Balanced manpage 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. tie my $count, Int
) requires the Type::Tie manpage;
stack traces on exceptions require the Devel::StackTrace manpage. The
the Reply::Plugin::TypeTiny manpage plugin for Reply requires Reply
(obviously). the Devel::LexAlias manpage may slightly increase the speed
of some of Type::Tiny's compiled coderefs.
the Type::Tiny::XS manpage is not required, but if available provides a speed
boost for some type checks. (Setting the environment variable
PERL_TYPE_TINY_XS
to false, or setting PERL_ONLY
to true will
suppress the use of Type::Tiny::XS, even if it is available.)
The test suite additionally requires the Test::More manpage, the Test::Fatal manpage
and the Test::Requires manpage. 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 inc
directory, so you do not need to
install them separately.
If using Type::Tiny in conjunction with Moo, then at least Moo 1.001000 is recommended. If using Type::Tiny with Moose, then at least Moose 2.0600 is recommended. If using Type::Tiny with Mouse, then at least Mouse 1.00 is recommended. Type::Tiny is mostly untested against older versions of these packages.
Type::Tiny is similar in aim to Specio. The major differences are
Type::Tiny libraries expose a similar interface to the MooseX::Types manpage libraries. In most cases you should be able to rewrite a the MooseX::Types manpage library to use Type::Tiny pretty easily.
Type::Tiny is faster and supports coercions.
the Scalar::Does manpage is somewhat of a precursor to Type::Tiny, but has now been rewritten to use Type::Tiny internally.
It gives you a does($value, $type)
function that is roughly equivalent
to $type->check($value)
except that $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
$value->DOES($type)
.
Please report any bugs to http://rt.cpan.org/Dist/Display.html.
IRC: > support is available through in the #moops > channel on irc.perl.org.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013-2014 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.
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.
Type::Tiny::Manual - an overview of Type::Tiny |