Remix.run Logo
voidhorse 4 days ago

I'm not sure why people are debating the merits of sum types versus sealed types in response to this. I prefer functional languages myself, but you are entirely correct that sealed types can fully model sum types and that the type level discrimination you get for free via subtyping makes them slightly easier to define and work with than sum types reliant on polymorphism.

Operationally these systems and philosophies are quite different, but mathematically we are all working in more work less an equivalent category and all the type system shenanigans you have in FP are possible in OOP modulo explicit limits placed on the language and vice versa.

ackfoobar 4 days ago | parent [-]

> I'm not sure why

Me neither.

> you are entirely correct that sealed types can fully model sum types

I want to be wrong, in that case I learn something new.