use Scalar::Util qw( blessed reftype );
use Moose::Exporter;
-our $VERSION = '0.92';
+our $VERSION = '0.95';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
register_type_constraint
match_on_type )
],
- _export_to_main => 1,
);
## --------------------------------------------------------
use re "eval";
my $valid_chars = qr{[\w:\.]};
- my $type_atom = qr{ $valid_chars+ };
+ my $type_atom = qr{ (?>$valid_chars+) }x;
+ my $ws = qr{ (?>\s*) }x;
my $any;
- my $type = qr{ $valid_chars+ (?: \[ \s* (??{$any}) \s* \] )? }x;
+ my $type = qr{ $type_atom (?: \[ $ws (??{$any}) $ws \] )? }x;
my $type_capture_parts
- = qr{ ($valid_chars+) (?: \[ \s* ((??{$any})) \s* \] )? }x;
+ = qr{ ($type_atom) (?: \[ $ws ((??{$any})) $ws \] )? }x;
my $type_with_parameter
- = qr{ $valid_chars+ \[ \s* (??{$any}) \s* \] }x;
+ = qr{ $type_atom \[ $ws (??{$any}) $ws \] }x;
- my $op_union = qr{ \s* \| \s* }x;
- my $union = qr{ $type (?: $op_union $type )+ }x;
+ my $op_union = qr{ $ws \| $ws }x;
+ my $union = qr{ $type (?> (?: $op_union $type )+ ) }x;
$any = qr{ $type | $union }x;
subtype 'Ref' => as 'Defined' => where { ref($_) } =>
optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Ref;
-subtype 'Str' => as 'Value' => where {1} =>
+subtype 'Str' => as 'Value' => where { ref(\$_) eq 'SCALAR' } =>
optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Str;
subtype 'Num' => as 'Str' =>
=item B<< match_on_type $value => ( $type => \&action, ... ?\&default ) >>
This is a utility function for doing simple type based dispatching similar to
-match/case in O'Caml and case/of in Haskell. It is not as featureful as those
+match/case in OCaml and case/of in Haskell. It is not as featureful as those
languages, nor does not it support any kind of automatic destructuring
bind. Here is a simple Perl pretty printer dispatching over the core Moose
types.
=head1 BUGS
-All complex software has bugs lurking in it, and this module is no
-exception. If you find a bug please either email me, or add the bug
-to cpan-RT.
+See L<Moose/BUGS> for details on reporting bugs.
=head1 AUTHOR
=head1 COPYRIGHT AND LICENSE
-Copyright 2006-2009 by Infinity Interactive, Inc.
+Copyright 2006-2010 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>