Revisiting variance

Isn’t this just a badly implemented TypeIs function? The generic type claims its _merge_func accepts tuples of T but the function never checks whether that actually is the case. From what I understood before your issue is different from it just being hard (or in this case impossible afaik) to correctly implement safe TypeIs functions, right? If I use the unsafe_typeis2 function in kaboom2 I also don’t get the same inferred type but MutabilityIsADistraction[Any], even with mypy.

I made a variant of your example that only uses covariant types and has, from my pov, the same behaviour in this playground. This does at least indicate that there are serious difficulties with actually writing correct TypeIs functions that also correctly cover subtypes. But from what I’ve understood that is not your primary concern here?

1 Like