Syntactic sugar for union cases in match statements

While I would disagree that Unions are ADTs as people are familiar with the term from other languages, I would agree that the problems ADTs help solve are already solvable with things python has.

Unions are a type-system exclusive construct, yes you can do a limited number of things with them at runtime, but that’s not their primary purpose and very little exists around that. This is partially intentional, as having runtime behavior on typing features that isn’t clearly separated has lead to problems of inconsistency like…


Even isinstance’s second parameter accepting a Union has been considered a mistake by a few people in hindsight. This recently came up in another discussion with adding isinstance support to other type-sytem parts (quoted below).

After some consideration, I’m negative on adding match support to Union but positive on an ADT construct that works with or without the type system and Unions (though it should be compatible for typing users, it should work for non-typing uses given the motivations)