Re: coerce a sub-subtype
[email protected] (Karen Etheridge) Mon, 16 Jun 2014 13:07:23 -0700
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <20140616200723.GP55364@tequila> |
On Mon, Jun 16, 2014 at 07:41:29PM +0000, John Macdonald wrote: > In general, though, having a way of inheriting subtypes could be potentially a big saving in this sort of case. This would be a really nice feature to have in MooseX::Types - no one's made this happen yet though, sadly. (Patches welcome!) :) Also, Types::Tiny does have an option to support this already. I'd strongly suggest avoiding declaring named types using Moose::Util::TypeConstraints though, because such types are global (as are their coercions), which can cause nasty action-at-a-distance errors. You can get around this problem by declaring types only as local lexicals, e.g: my $type = subtype as ...;