.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Type::Nano 3"
.TH Type::Nano 3 "2020-11-18" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Type::Nano \- simple type constraint library for testing
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Type::Nano qw(Int);
\&
\& Int\->check("42"); # true
.Ve
.SH "RATIONALE"
.IX Header "RATIONALE"
This is a really basic implementation of Type::API::Constraint for
testing modules that make use of type constraints, such as Type::Tie.
.PP
I'll stress that this module is \fIonly\fR intended for use in testing. It was
created to eliminate Type::Tie's testing dependency on Types::Standard.
If your code supports Type::Nano, then your code should also \fBautomatically\fR
support Type::Tiny, Specio, MooseX::Types, and MouseX::Types
with no extra effort. (Of course, some of those libraries do have some more
features you may want to make extra effort to use! Inlining, for example.)
.PP
Type::Nano is not recommended for use in regular application code.
Type::Tiny while bigger than Type::Nano, will be \fImuch\fR faster at
runtime, and offers better integration with Moo, Moose, Mouse, and a
wide variety of other tools. Use that instead.
.PP
All that having been said, Type::Nano is compatible with:
Type::Tie, Moo, Type::Tiny (e.g. you can use Type::Tiny's
implementation of \f(CW\*(C`ArrayRef\*(C'\fR and Type::Nano's implementation of
\&\f(CW\*(C`Int\*(C'\fR, and combine them as \f(CW\*(C`ArrayRef[Int]\*(C'\fR), Class::XSConstructor,
and Variable::Declaration.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
.SS "Object-Oriented Interface"
.IX Subsection "Object-Oriented Interface"
\fIConstructor\fR
.IX Subsection "Constructor"
.ie n .IP """Type::Nano\->new(%parameters)""" 4
.el .IP "\f(CWType::Nano\->new(%parameters)\fR" 4
.IX Item "Type::Nano->new(%parameters)"
The constructor supports named parameters called \f(CW\*(C`name\*(C'\fR (a string),
\&\f(CW\*(C`constraint\*(C'\fR (a coderef expected to return a boolean), and \f(CW\*(C`parent\*(C'\fR
(a blessed Type::Nano object). Any other parameters passed to the
constructor will be stored in the blessed hashred returned, but are ignored
by Type::Nano.
.PP
\fIMethods\fR
.IX Subsection "Methods"
.PP
Types support the following methods:
.ie n .IP """$type\->check($value)""" 4
.el .IP "\f(CW$type\->check($value)\fR" 4
.IX Item "$type->check($value)"
Checks the value against the constraint; returns a boolean.
.ie n .IP """$type\->get_message($failing_value)""" 4
.el .IP "\f(CW$type\->get_message($failing_value)\fR" 4
.IX Item "$type->get_message($failing_value)"
Returns an error message. Does not check the value.
.PP
Types overload \f(CW\*(C`&{}\*(C'\fR to do something like:
.PP
.Vb 1
\& $type\->check($value) or croak($type\->get_message($value))
.Ve
.SS "Exports"
.IX Subsection "Exports"
This module optionally exports the following type constraints:
.IP "\(bu" 4
Any
.IP "\(bu" 4
Defined
.IP "\(bu" 4
Undef
.IP "\(bu" 4
Ref
.IP "\(bu" 4
ArrayRef
.IP "\(bu" 4
HashRef
.IP "\(bu" 4
CodeRef
.IP "\(bu" 4
Object
.IP "\(bu" 4
Str
.IP "\(bu" 4
Bool
.IP "\(bu" 4
Num
.IP "\(bu" 4
Int
.PP
It also optionally exports the following functions for creating new type
constraints:
.IP "\(bu" 4
\&\f(CW\*(C`type $name, $coderef\*(C'\fR or \f(CW\*(C`type $coderef\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`class_type $class\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`role_type $role\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`duck_type $name, \e@methods\*(C'\fR or \f(CW\*(C`duck_type \e@methods\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`enum $name, \e@values\*(C'\fR or \f(CW\*(C`enum \e@values\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`union $name, \e@types\*(C'\fR or \f(CW\*(C`union \e@types\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`intersection $name, \e@types\*(C'\fR or \f(CW\*(C`intersection \e@types\*(C'\fR
.SH "BUGS"
.IX Header "BUGS"
Please report any bugs to
<http://rt.cpan.org/Dist/Display.html?Queue=Type\-Tie>.
.SH "SUPPORT"
.IX Header "SUPPORT"
\&\fB\s-1IRC:\s0\fR support is available through in the \fI#moops\fR channel
on irc.perl.org <http://www.irc.perl.org/channels.html>.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Type::API.
.SH "AUTHOR"
.IX Header "AUTHOR"
Toby Inkster <tobyink@cpan.org>.
.SH "COPYRIGHT AND LICENCE"
.IX Header "COPYRIGHT AND LICENCE"
This software is copyright (c) 2018\-2019 by Toby Inkster.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
.SH "DISCLAIMER OF WARRANTIES"
.IX Header "DISCLAIMER OF WARRANTIES"
\&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0