GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Type::Nano(3) User Contributed Perl Documentation Type::Nano(3)

Type::Nano - simple type constraint library for testing

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

This is a really basic implementation of Type::API::Constraint for testing modules that make use of type constraints, such as Type::Tie.

I'll stress that this module is only 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 automatically 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.)

Type::Nano is not recommended for use in regular application code. Type::Tiny while bigger than Type::Nano, will be much faster at runtime, and offers better integration with Moo, Moose, Mouse, and a wide variety of other tools. Use that instead.

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 "ArrayRef" and Type::Nano's implementation of "Int", and combine them as "ArrayRef[Int]"), Class::XSConstructor, and Variable::Declaration.

Constructor
"Type::Nano->new(%parameters)"
The constructor supports named parameters called "name" (a string), "constraint" (a coderef expected to return a boolean), and "parent" (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.

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.

Types overload "&{}" to do something like:

  $type->check($value) or croak($type->get_message($value))

This module optionally exports the following type constraints:
  • Any
  • Defined
  • Undef
  • Ref
  • ArrayRef
  • HashRef
  • CodeRef
  • Object
  • Str
  • Bool
  • Num
  • Int

It also optionally exports the following functions for creating new type constraints:

  • "type $name, $coderef" or "type $coderef"
  • "class_type $class"
  • "role_type $role"
  • "duck_type $name, \@methods" or "duck_type \@methods"
  • "enum $name, \@values" or "enum \@values"
  • "union $name, \@types" or "union \@types"
  • "intersection $name, \@types" or "intersection \@types"

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

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

Type::API.

Toby Inkster <tobyink@cpan.org>.

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.

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.
2020-11-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.