Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 88951
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: perl [...] toby.ink
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Union and Intersection should still allow constraint/inlined attributes
Right now, if you try to define either of these attributes, U/I will fatally croak, despite the documentation implying that it's still allowed (even if it's a bad idea). Use case: Two complex types that need some constraint/inlined optimization, but you still otherwise want to indicate that it really is a Union or Intersection of those types. This would give me the ability to optimize away while still having the proper validate_explain logic for those types. I realize this is sort of like lying to validate/validate_explain, because it's not using the actual constraint/inlined to test the failure, but that's part of the reason why overriding those would still be a "bad idea". Caveat utilitor.
I agree that the documentation differs from the implementation, but I think the documentation needs fixing rather than the implementation. For your use case, there's no need to add a constraint directly to the union; you can create a subtype of the union and add the constraint to that. You still get decent explanations... perl -MTypes::Standard=-types -E'(HashRef|ArrayRef)->create_child_type->assert_valid(123)' Type::Utils' "declare...as" stuff creates a subtype automatically, so the following should just work: declare NonEmptyRef, as HashRef | ArrayRef, where { !!( ref($_) eq 'HASH' ? %$_ : @$_ ) };
Improved the documentation in the repo.
Documentation fixed in 0.028.