1Type::Tiny::Manual(3) User Contributed Perl DocumentationType::Tiny::Manual(3)
2
3
4

NAME

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

SYNOPSIS

9       Type::Tiny is a small class for writing type constraints, inspired by
10       Moose's type constraint API. It has only one non-core dependency (and
11       even that is simply a module that was previously distributed as part of
12       Type::Tiny but has since been spun off), and can be used with Moose,
13       Mouse and Moo (or none of the above).
14
15       Type::Tiny is bundled with Type::Library a framework for organizing
16       type constraints into collections.
17
18       Also bundled is Types::Standard, a Moose-inspired library of useful
19       type constraints.
20
21       Type::Params is also provided, to allow very fast checking and coercion
22       of function and method parameters.
23

SEE ALSO

25       ·   Libraries - how to build a type library with Type::Tiny,
26           Type::Library and Type::Utils
27
28       ·   Coercions - adding coercions to type constraints
29
30       ·   Using with Moose - how to use Type::Tiny and Type::Library with
31           Moose
32
33       ·   Using with Mouse - how to use Type::Tiny and Type::Library with
34           Mouse
35
36       ·   Using with Moo - how to use Type::Tiny and Type::Library with Moo
37
38       ·   Using with Other OO Frameworks - how to use Type::Tiny and
39           Type::Library with other OO frameworks
40
41       ·   Type::Tiny and friends don't need to be used within an OO
42           framework. See FreeMind::Node for an example that does not.
43
44       ·   Processing arguments to subs - coerce and validate arguments to
45           functions and methods.
46
47       ·   Other modules using Type::Tiny in interesting ways: Type::Tie,
48           Test::Mocha, Scalar::Does, Set::Equivalence...
49
50       ·   Optimization - squeeze the most out of your CPU.
51
52       ·   Type::Tiny maintenance policies - the stability policy.
53

DEPENDENCIES

55       Type::Tiny requires at least Perl 5.6.1, though certain Unicode-related
56       features (e.g. non-ASCII type constraint names) may work better in
57       newer versions of Perl.
58
59       Type::Tiny requires Exporter::Tiny, a module that was previously
60       bundled in this distribution, but has since been spun off as a separate
61       distribution. Don't worry - it's quick and easy to install.
62
63       At run-time, Type::Tiny also requires the following modules: B,
64       B::Deparse, Carp, Data::Dumper, Scalar::Util, Text::Balanced, overload,
65       strict and warnings. All of these come bundled with Perl itself. Prior
66       to Perl 5.8, Scalar::Util and Text::Balanced do not come bundled with
67       Perl and will need installing separately from the CPAN.
68
69       Certain features require additional modules. Tying a variable to a type
70       constraint (e.g. "tie my $count, Int") requires Type::Tie; stack traces
71       on exceptions require Devel::StackTrace. The Reply::Plugin::TypeTiny
72       plugin for Reply requires Reply (obviously). Devel::LexAlias may
73       slightly increase the speed of some of Type::Tiny's compiled coderefs.
74
75       Type::Tiny::XS is not required, but if available provides a speed boost
76       for some type checks. (Setting the environment variable
77       "PERL_TYPE_TINY_XS" to false, or setting "PERL_ONLY" to true will
78       suppress the use of Type::Tiny::XS, even if it is available.)
79
80       The test suite additionally requires Test::More, Test::Fatal and
81       Test::Requires. Test::More comes bundled with Perl, but if you are
82       using a version of Perl older than 5.14, you will need to upgrade to at
83       least Test::More version 0.96. Test::Requires and Test::Fatal (plus
84       Try::Tiny which Test::Fatal depends on) are bundled with Type::Tiny in
85       the "inc" directory, so you do not need to install them separately.
86
87       If using Type::Tiny in conjunction with Moo, then at least Moo 1.000000
88       is recommended. If using Type::Tiny with Moose, then at least Moose
89       2.0000 is recommended. If using Type::Tiny with Mouse, then at least
90       Mouse 1.00 is recommended. Type::Tiny is mostly untested against older
91       versions of these packages.
92

TYPE::TINY VERSUS X

94   Specio
95       Type::Tiny is similar in aim to Specio. The major differences are
96
97       ·   Type::Tiny is "tiny" (Specio will eventually have fewer
98           dependencies than it currently does, but is unlikely to ever have
99           as few as Type::Tiny);
100
101       ·   Specio has a somewhat nicer API (better method names; less
102           duplication), and its API is likely to improve further.
103           Type::Tiny's aims at complete compatibility with current versions
104           of Moose and Mouse, so there is a limit to how much I can deviate
105           from the existing APIs of (Moose|Mouse)::Meta::TypeConstraint.
106
107   MooseX::Types
108       Type::Tiny libraries expose a similar interface to MooseX::Types
109       libraries.  In most cases you should be able to rewrite a MooseX::Types
110       library to use Type::Tiny pretty easily.
111
112   MooX::Types::MooseLike
113       Type::Tiny is faster and supports coercions.
114
115   Scalar::Does
116       Scalar::Does is somewhat of a precursor to Type::Tiny, but has now been
117       rewritten to use Type::Tiny internally.
118
119       It gives you a "does($value, $type)" function that is roughly
120       equivalent to "$type->check($value)" except that $type may be one of a
121       list of pre-defined strings (instead of a Type::Tiny type constraint);
122       or may be a package name in which case it will be assumed to be a role
123       and checked with "$value->DOES($type)".
124

BUGS

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

SUPPORT

130       IRC: support is available through in the #moops channel on irc.perl.org
131       <http://www.irc.perl.org/channels.html>.
132

AUTHOR

134       Toby Inkster <tobyink@cpan.org>.
135
137       This software is copyright (c) 2013-2014, 2017-2019 by Toby Inkster.
138
139       This is free software; you can redistribute it and/or modify it under
140       the same terms as the Perl 5 programming language system itself.
141

DISCLAIMER OF WARRANTIES

143       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
144       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
145       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
146
147
148
149perl v5.30.0                      2019-07-26             Type::Tiny::Manual(3)
Impressum