Type::Utils - utility functions to make defining type constraints a little easier
package Types::Mine; use Type::Library -base; use Type::Utils; extends "Types::Standard"; declare "AllCaps", as "Str", where { uc($_) eq $_ }, inline_as { my $varname = $_[1]; "uc($varname) eq $varname" }; coerce "AllCaps", from "Str", via { uc($_) };
This module provides utility functions to make defining type constraints a little easier. By default, all of the functions documented below are exported, except subtype and type (use declare instead).
subtype
type
declare
The following are similar to the similarly named functions described in Moose::Util::TypeConstraints.
subtype $name, %options
subtype %options
type $name, %options
type %options
as $parent
where { BLOCK }
message { BLOCK }
inline_as { BLOCK }
class_type $name, { class => $package, %options }
class_type { class => $package, %options }
role_type $name, { role => $package, %options }
role_type { role => $package, %options }
duck_type $name, \@methods
duck_type \@methods
union $name, \@constraints
union \@constraints
enum $name, \@values
enum \@values
coerce $target, @coercions
from $source
via { BLOCK }
declare $name, %options
declare %options
declare is a function which works like subtype and type. In fact, the latter pair are just aliases for the former.
If the caller package inherits from Type::Library then any non-anonymous types declared in the package will be automatically installed into the library.
intersection $name, \@constraints
intersection \@constraints
Defines a type constraint which is the intersection of several existing constraints.
extends @library
Indicates that this type library extends other type libraries, importing their type constraints.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny.
Type::Tiny::Manual.
Type::Tiny, Type::Library, Types::Standard, Type::Coercion.
Type::Tiny::Class, Type::Tiny::Role, Type::Tiny::Duck, Type::Tiny::Enum, Type::Tiny::Union.
Moose::Util::TypeConstraints, Mouse::Util::TypeConstraints.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 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.
To install Type::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::Tiny
CPAN shell
perl -MCPAN -e shell install Type::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.