I think the purpose of an ADT expressed as sealed ...
# announcements
r
I think the purpose of an ADT expressed as sealed hierarchy is to enforce you contemplate all cases so it can guarantee a total function from your
Case
to
A
instead of being a partial function from
CaseSubtype
to
A
. If your sole intent is to perform effects with no useful return the compiler can't guarantee exhaustiveness since no return may also be a noop or uncontemplated case. IMO The
Unit
singleton value should be used to make clear you have not forgotten to cover any of the cases. Functions that don't explicitly return are already returning
Unit
as value implicitly.