1Type::Nano(3)         User Contributed Perl Documentation        Type::Nano(3)
2
3
4

NAME

6       Type::Nano - simple type constraint library for testing
7

SYNOPSIS

9         use Type::Nano qw(Int);
10
11         Int->check("42");  # true
12

RATIONALE

14       This is a really basic implementation of Type::API::Constraint for
15       testing modules that make use of type constraints, such as Type::Tie.
16
17       I'll stress that this module is only intended for use in testing. It
18       was created to eliminate Type::Tie's testing dependency on
19       Types::Standard.  If your code supports Type::Nano, then your code
20       should also automatically support Type::Tiny, Specio, MooseX::Types,
21       and MouseX::Types with no extra effort. (Of course, some of those
22       libraries do have some more features you may want to make extra effort
23       to use! Inlining, for example.)
24
25       Type::Nano is not recommended for use in regular application code.
26       Type::Tiny while bigger than Type::Nano, will be much faster at
27       runtime, and offers better integration with Moo, Moose, Mouse, and a
28       wide variety of other tools. Use that instead.
29
30       All that having been said, Type::Nano is compatible with: Type::Tie,
31       Moo, Type::Tiny (e.g. you can use Type::Tiny's implementation of
32       "ArrayRef" and Type::Nano's implementation of "Int", and combine them
33       as "ArrayRef[Int]"), Class::XSConstructor, and Variable::Declaration.
34

DESCRIPTION

36   Object-Oriented Interface
37       Constructor
38
39       "Type::Nano->new(%parameters)"
40           The constructor supports named parameters called "name" (a string),
41           "constraint" (a coderef expected to return a boolean), and "parent"
42           (a blessed Type::Nano object). Any other parameters passed to the
43           constructor will be stored in the blessed hashred returned, but are
44           ignored by Type::Nano.
45
46       Methods
47
48       Types support the following methods:
49
50       "$type->check($value)"
51           Checks the value against the constraint; returns a boolean.
52
53       "$type->get_message($failing_value)"
54           Returns an error message. Does not check the value.
55
56       Types overload "&{}" to do something like:
57
58         $type->check($value) or croak($type->get_message($value))
59
60   Exports
61       This module optionally exports the following type constraints:
62
63       ·   Any
64
65       ·   Defined
66
67       ·   Undef
68
69       ·   Ref
70
71       ·   ArrayRef
72
73       ·   HashRef
74
75       ·   CodeRef
76
77       ·   Object
78
79       ·   Str
80
81       ·   Bool
82
83       ·   Num
84
85       ·   Int
86
87       It also optionally exports the following functions for creating new
88       type constraints:
89
90       ·   "type $name, $coderef" or "type $coderef"
91
92       ·   "class_type $class"
93
94       ·   "role_type $role"
95
96       ·   "duck_type $name, \@methods" or "duck_type \@methods"
97
98       ·   "enum $name, \@values" or "enum \@values"
99
100       ·   "union $name, \@types" or "union \@types"
101
102       ·   "intersection $name, \@types" or "intersection \@types"
103

BUGS

105       Please report any bugs to
106       <http://rt.cpan.org/Dist/Display.html?Queue=Type-Tie>.
107

SUPPORT

109       IRC: support is available through in the #moops channel on irc.perl.org
110       <http://www.irc.perl.org/channels.html>.
111

SEE ALSO

113       Type::API.
114

AUTHOR

116       Toby Inkster <tobyink@cpan.org>.
117
119       This software is copyright (c) 2018-2019 by Toby Inkster.
120
121       This is free software; you can redistribute it and/or modify it under
122       the same terms as the Perl 5 programming language system itself.
123

DISCLAIMER OF WARRANTIES

125       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
126       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
127       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
128
129
130
131perl v5.30.0                      2019-07-26                     Type::Nano(3)
Impressum