X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FParameterizable.pm;h=e287889b0c34d4dbce7379097194dd03a6ca1437;hb=52ed7d4d952fd6eaf67bb394eabe215cd2eaf746;hp=f1db92a38191386297ca68b8cb4ad8cd081dabf7;hpb=910bb5389be9e75022a3bba041dfe75db4ccc4b4;p=gitmo%2FMooseX-Dependent.git diff --git a/lib/MooseX/Types/Parameterizable.pm b/lib/MooseX/Types/Parameterizable.pm index f1db92a..e287889 100644 --- a/lib/MooseX/Types/Parameterizable.pm +++ b/lib/MooseX/Types/Parameterizable.pm @@ -262,16 +262,32 @@ is a subtype of the parameterizable "Varchar" and it inherits coercions from its parent. This may be a bit surprising to L developers, but I believe this is the actual desired behavior. -You can of course add extra coercions to a parameterized type: +You can of course add new coercions to a subtype of a parameterizable type: - subtype Max40CharStr, - as Varchar[40]; + subtype MySpecialVarchar, + as Varchar; - coerce Max40CharStr, + coerce MySpecialVarchar, from ... -In which case this new parameterized type would inherit coercions from it's parent -parameterizable type (Varchar), as well as the additional coercions you've added. +In which case this new parameterizable type would NOT inherit coercions from +it's parent parameterizable type (Varchar). This is done in keeping with how +generally speaking L type constraints avoid complicated coercion inheritance +schemes, however I am open to discussion if there are valid use cases. + +NOTE: One thing you can't do is add a coercion to an already parameterized type. +Currently the following would throw a hard error: + + subtype 40CharStr, + as Varchar[40]; + + coerce 40CharStr, ... # BANG! + +This limitation is enforced since generally we expect coercions on the parent. +However if good use cases arise we may lift this in the future. + +In general we are trying to take a conservative approach that keeps in line with +how most L authors expect type constraints to work. =head2 Recursion