While I am using Moose::Util::TypeConstraints, I simplified my typenames for this discussion, so the Type::Chr names I used below are all actually prefixed by BoutrosLab::TSVStream::... so there is less concern about namespace collison. Using local lexical types doesn't work directly when you want to refer to the types in a sub-type defined in a separate mdule in a differnt lexical scope.
I've put a TODO into my code to convert to Type::Tiny when I get to the point of adding more subtype variants. John Macdonald Software Engineer Ontario Institute for Cancer Research MaRS Centre 661 University Avenue Suite 510 Toronto, Ontario Canada M5G 0A3 Tel: Email: john.macdon...@oicr.on.ca Toll-free: 1-866-678-6427 Twitter: @OICR_news www.oicr.on.ca This message and any attachments may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this message in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this message may not be that of the organization. ________________________________________ From: Karen Etheridge [p...@froods.org] Sent: June 16, 2014 4:07 PM To: moose@perl.org Subject: Re: coerce a sub-subtype 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 ...;