Allow sealed interfaces without subclasses
Jakob Brünker
jakob.bruenker at gmail.com
Thu Nov 26 00:46:10 UTC 2020
Hi all,
While I like sealed classes a lot in general, it's lacking one simple
feature that prevents it from being used to fully emulate algebraic data
types: You cannot make an uninhabited type (modulo null), since you cannot
have a sealed interface without subclasses.
Is there a good reason to disallow this? It does come in handy every once
in a while in languages where it's possible, especially when trying to
convince the type checker that a particular combination of patterns is
impossible. As a data point, in Haskell, this used to be impossible, but
was later adopted into the language standard, and in fact is used in the
standard library to define such a type under the name Data.Void.
Thanks,
Jakob
More information about the amber-dev
mailing list