Subject: | support more overloads in type constraints |
MooseX::Types types support more overloads than native types, which violates the principle of least surprise.
this works:
use Moose::Util::TypeConstraints 'class_type';
use MooseX::Types::Moose 'HashRef';
my $type1 = HashRef | class_type('Foo');
this does not:
my $type2 = $type1 | class_type('Bar');
It actually *appears* to work, but what you get in $type2 is a string created
by the bitwise ORing of the stringification of the two input types. We don't
find out until runtime that this is totally broken!
It should be quite straightforward to overload '|' on
Moose::Meta::TypeConstraint objects and create a ::Union from the inputs.