Eric's feedback is also important to consider. What compelling benefit does this new type system feature provide over just using a Union?
One of the benefits that the base-class approach has over the Union approach is that the base type can define additional state and methods that the variants can implement, or can be used when referring to the base type. I see this as being more a more general and flexible ADT. A very simplistic example: from dataclasses import dataclass from enum import Enum, auto class UsState(Enum): Alabama = auto() Alaska = auto() # --snip-- # @sealed class Coin: value: int def value_in_cents(self) -> int: return self.value @dataclass class Nickle(Coin): value = 5 @dataclass class Dime(Coin): value = 10 @dataclass class Quarter(Coin): value = 25 us_state: UsState def get_value(coin: Coin) -> int: match coin: case Quarter(state): print(f"State quarter from {state}") case _: pass return coin.value_in_cents() Also as reference, I did a language survey of how other languages handle ADTs (to help motivate using the name `sealed` or use something else). ## `sealed` - Kotlin: https://kotlinlang.org/docs/sealed-classes.html - Scala 2: https://docs.scala-lang.org/tour/pattern-matching.html - Java 17: https://openjdk.java.net/jeps/409 ## `enum` - Scala 3: https://docs.scala-lang.org/scala3/reference/enums/adts.html - Rust: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html - Swift: https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html ## Pipe (`|`) - Haskell: https://wiki.haskell.org/Algebraic_data_type - OCaml: https://cs3110.github.io/textbook/chapters/data/algebraic_data_types.html - F#: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/discrimina... ## Manual Property - TypeScript: https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.ht... ## Don't have ADTs - Go: https://go.dev/doc/faq#variant_types