NAME
Types::Set - Set::Equivalence-related type constraints
SYNOPSIS
package Band {
use Moose;
use Types::Standard qw( InstanceOf );
use Types::Set qw( Set );
has members => (
is => 'ro',
isa => Set[ InstanceOf['Person'] ],
coerce => 1,
default => sub { +[] },
handles => {
add_member => 'insert',
has_member => 'contains',
member_count => 'size',
}
);
}
DESCRIPTION
Types::Set is a type constraint library built using Type::Tiny; compatible with Moose, Mouse, Moo and more.
Type constraints
AnySet
-
This type constraint is satisfied by any blessed object that provides
insert
,delete
,members
andcontains
methods. Set
-
A blessed Set::Equivalence object.
This may be parameterized with another type constraint; for example,
Set[Num]
is a set of numbers. In this case, not only must all the set members be numbers, but also the set itself must have a type constraint ofNum
(or a subtype ofNum
, such asInt
) attached, which will prevent non-numeric values from being inserted into the set later.This type can coerce from
ArrayRef
andAnySet
. MutableSet
-
Like
Set
, but must be a mutable set. Similar parameterization.This type can coerce from
ImmutableSet
,ArrayRef
andAnySet
. ImmutableSet
-
Like
Set
, but must not be a mutable set. Similar parameterization.This type can coerce from
MutableSet
,ArrayRef
andAnySet
.
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Set-Equivalence.
SEE ALSO
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.