Description
Ok, so the title is slightly simplified from my actual use-case, which is:
RGB = tuple[float, float, float]
BorderColor = RGB | tuple[RGB, RGB, RGB, RGB] # 1st must have length 3; 2nd must have length 4!
In either case, I get an error message saying that multiple array-like types are not supported.
Yet, the fact that all the array-like types in my union have different lengths should be readily available from the typing information!
There is an additional hint in my real use-case above, beyond just the length, which is that the 1st element of the first branch is float, whereas the first element of the 2nd branch is tuple. These two types are clearly incompatible with each other, since their array depth is different, so could therefore serve as an automatic "tag" (in addition to length), theoretically.
I.e., if there were a computed "tag" for all-tuple unions consisting of (first element type's tag, length), that would solve pretty much every use-case I can think of along these lines. Or, just length, if combining it recursively with the first element type's tag is too complicated, which would still solve the use-cases I currently care about (however, that alone would not be enough if my BorderColor happened to be made up of RGBA's instead of RGB.)
So it seems like this kind of pattern should be supported, at least to some extent?
Description
Ok, so the title is slightly simplified from my actual use-case, which is:
In either case, I get an error message saying that multiple array-like types are not supported.
Yet, the fact that all the array-like types in my union have different lengths should be readily available from the typing information!
There is an additional hint in my real use-case above, beyond just the length, which is that the 1st element of the first branch is
float, whereas the first element of the 2nd branch istuple. These two types are clearly incompatible with each other, since their array depth is different, so could therefore serve as an automatic "tag" (in addition to length), theoretically.I.e., if there were a computed "tag" for all-tuple unions consisting of (first element type's tag, length), that would solve pretty much every use-case I can think of along these lines. Or, just length, if combining it recursively with the first element type's tag is too complicated, which would still solve the use-cases I currently care about (however, that alone would not be enough if my BorderColor happened to be made up of RGBA's instead of RGB.)
So it seems like this kind of pattern should be supported, at least to some extent?