In addition to the underscore pattern (meh - makes it easy to forget about a
case added later) and refactoring types, I can also recommend extracting a
function. You still have to have n cases but each of them will be short.
--
You received this message because you are subscribed to the
>
> I generally don't like using equality test on union types because that
> makes your code more prone to errors - later on you might decide to add /
> remove some types from union type.
I'm on board with that. I try to avoid catch-all underscores in case
statements for the same reason. But if
I generally don't like using equality test on union types because that
makes your code more prone to errors - later on you might decide to add /
remove some types from union type.
On Friday, December 9, 2016 at 4:57:48 PM UTC+1, Nick H wrote:
>
> You can also do equality tests on type values,
Op vrijdag 9 december 2016 16:57:48 UTC+1 schreef Nick H:
>
> This only works if your type values aren't storing any data.
>
The equality test can be done if you are *not trying to pattern match* on
the data in the type.
So
-- will work
if someValue == Just 42 then
doStuffWith 42
is fine,