I've created a branch in topic/union-type-resolver that adds a method
(find_type_for) to TypeConstraint::Union.  It allows you to resolve
which of the member type constraints a given value matches first.  I
say first because it's possible for it to match more than one.  So if
you have a Union TC for Str|Undef:

  $type_constraint->find_type_for('A String') # returns the member
type constraint for Str
  $type_constraint->find_type_for(undef) # returns the member type
constraint for Undef

The reason for this feature is to enable a feature of MooseX::Storage.
 It presently barfs when given something like Str|ArrayRef even though
both of these types are supported for storage.  With this feature
MooseX::Storage can determine which storage mechanism to use for a
given value of an attribute.  I'll hold onto that patch until the fate
of this one is determined.

All tests pass (added some to the existing union tests) and docs are included.

-- 
Cory 'G' Watson
http://www.onemogin.com

Reply via email to