Re:Guide to Java Virtual Threads
by DeathArrow on Friday March 17, 2023 @05:44AM
(#35194998)
>sealed hierarchies for sums
I wouldn't call that a good example of sum types. You can use sealed classes or other mechanism in C# to emulate sum types. I was thinking about something built in the language.
Re:Guide to Java Virtual Threads
by pron on Friday March 17, 2023 @07:03AM
(#35195433)
It's built into the language and the VM (the VM enforces the "sealedness", and pattern matching uses it for exhaustiveness checks). It's just that all types in Java are nominal.
I wouldn't call that a good example of sum types. You can use sealed classes or other mechanism in C# to emulate sum types. I was thinking about something built in the language.
Example:
type IntOrBool = | I of int | B of bool