You can only check for the subset of values. E.g. ...
# arrow
s
You can only check for the subset of values. E.g. in my above example,
y
is declared as
Sealed2
, which means that any exhaustive
when
clause need only have branches for
V3
and
V4
. Of course,
x
, being of type
Sealed1
, a
when
clause needs to check for all values, but could ‘bundle’ all values of
Sealed2
by just doing
is Sealed2 ->
. If you need to keep them apart, i.e. not pollute the entire
Error
set of values with new ones that are used just for
checkUserIsOldEnough
, you must create a entire new set of error-values for that new function, not sub-classing
Error
. If All errors must have a common parent-class, make that class an abstract class or interface, not ‘sealed’.