Made a relatively short post about modeling open and closed universes of choices (enums are not always appropriate!):
Conversation
Awesome post!
Regarding footnote 4, Scala has kind of gone the other way: it has always used sealed traits for defining tagged unions with exhaustive matching, but it now provides an `enum` syntax as sugar for this pattern: docs.scala-lang.org/scala3/referen
1
2
Interestingly people seem to have the impression that Scala's tagged unions are a 'hack'… hopefully the enum syntax might help people be less scared of them, even if it really is the same thing under the hood! 😅
1
1
Hah! Is there an equivalent to non-exhaustive enums, where the API is flexible enough to add new variants without causing a breaking change?
1
I think you can get that by just using regular inheritance, without putting `sealed` on the parent class/trait. There's also now an `open` modifier that lets you signal that 'intent': docs.scala-lang.org/scala3/referen
1
1
Another point in the design space is OCaml's 'polymorphic variants' which you can mark as 'open' using the `[> ... ]` syntax:
- ocaml.org/learn/tutorial
- ocaml.org/manual/lablexa
- dev.realworldocaml.org/variants.html#

