4 ms·
You also want the subclasses to be `sealed`. Ideally you would want to write `abstract sealed` for `Discount` too, but C# does not allow it. CIL does support i
by sparkie 3y ago
You also want the subclasses to be `sealed`.
Ideally you would want to write `abstract sealed` for `Discount` too, but C# does not allow it. CIL does support it however, and it is how F# implements sum types. There's no reason I see for C# to continue enforcing this restriction, and lifting it would allow us to write proper DUs.
- ctenb 3y agoWhile I tend to make the SUM type cases sealed, it is theoretically not required to make the sum type closed. All subtypes of a case belong by definition to that case. So any code that handles the defined cases also handles the subclasses implicitly.