Type::Nano(3pm)
π Type::Nano π
okay bestie, so this is Type::Nano, and it's a page from the User Contributed Perl Documentation section (that's the 3pm part, iykyk). buckle up, it's short and it's adorable.
β¨ NAME β¨
Type::Nano β a simple type constraint library for testing π§ͺβ¨
πΈ SYNOPSIS πΈ
use Type::Nano qw(Int);
Int->check("42"); # true
literally that's it. that's the whole vibe. Int->check("42") and it's giving true. slay. π
π¦ RATIONALE π¦
okay so this is a really basic implementation of Type::API::Constraint, and its whole purpose in life is testing modules that make use of type constraints β think Type::Tie and friends. π
and I need you to hear me on this one, bestie: this module is only intended for use in testing. it was literally created to eliminate Type::Tie's testing dependency on Types::Standard. no cap. and here's the cute part β if your code supports Type::Nano, then your code should automatically support Type::Tiny, Specio, MooseX::Types, and MouseX::Types with no extra effort at all. π«Ά (obviously some of those libraries do have extra features you might want to make extra effort for! inlining, for example. just saying. π)
β οΈType::Nanois not recommended for use in regular application code.Type::Tiny, while bigger thanType::Nano, will be much faster at runtime, and offers better integration withMoo,Moose,Mouse, and a wide variety of other tools. use that instead. periodt. π
all that having been said tho β Type::Nano is compatible with: Type::Tie, Moo, Type::Tiny (like, you can use Type::Tiny's implementation of ArrayRef and Type::Nano's implementation of Int, and combine them as ArrayRef[Int] β iconic β¨), Class::XSConstructor, and Variable::Declaration. π
π DESCRIPTION π
π Object-Oriented Interface π
π Constructor π
Type::Nano->new(%parameters)β the constructor supports named parameters calledname(a string),constraint(a coderef expected to return a boolean), andparent(a blessedType::Nanoobject). any other parameters you pass to the constructor will be stored in the blessed hashred returned, butType::Nanojust ignores them. lowkey a little storage unit. π
π Methods π
types support the following methods:
$type->check($value)β checks the value against the constraint; returns a boolean. π§$type->get_message($failing_value)β returns an error message. does not check the value. (so don't come for it, it's just the messenger π)
types overload &{} to do something like:
$type->check($value) or croak($type->get_message($value))
β Exports β
this module optionally exports the following type constraints:
AnyDefinedUndefRefArrayRefHashRefCodeRefObjectStrBoolNumInt
it also optionally exports the following functions for creating new type constraints:
type $name, $coderefortype $coderefclass_type $classrole_type $roleduck_type $name, \@methodsorduck_type \@methodsenum $name, \@valuesorenum \@valuesunion $name, \@typesorunion \@typesintersection $name, \@typesorintersection \@types
π BUGS π
please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tie. not me being the messenger again π go tell the tracker, bestie.
π¬ SUPPORT π¬
IRC: support is available through in the #moops channel on irc.perl.org β http://www.irc.perl.org/channels.html. come vibe with us. π«Ά
π₯ SEE ALSO π₯
Type::API. π
βοΈ AUTHOR βοΈ
Toby Inkster <tobyink@cpan.org>. π
π COPYRIGHT AND LICENCE π
this software is copyright (c) 2018-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. π¦
π 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.
fr fr, that's the whole disclaimer, and it means what it says β no promises, no cap. π
and that's the whole page, bestie! this one came out of perl v5.32.1, dated 2021-02-07, and it's filed under Type::Nano(3pm). mwah π
β¨
π¦ where this page comes from
- ubuntu jammy: libtype-tie-perl 0.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms