The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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, %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 }

Other

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.

BUGS

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

SEE ALSO

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.

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.