NAME
Type::Utils - utility functions to make defining type constraints a little easier
SYNOPSIS
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($_) };
DESCRIPTION
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).
Moose::Util::TypeConstraints-like
The following are similar to the similarly named functions described in Moose::Util::TypeConstraints.
subtype $name, %optionssubtype %optionstype $name, %optionstype %optionsas $parentwhere { 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, \@methodsduck_type \@methodsunion $name, \@constraintsunion \@constraintsenum $name, \@valuesenum \@valuescoerce $target, @coercionsfrom $sourcevia { BLOCK }
Other
declare $name, %optionsdeclare %options-
declareis a function which works likesubtypeandtype. 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, \@constraintsintersection \@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.
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny.
SEE ALSO
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.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
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.
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.