3 ms·
If you have: foo (Just a) = bar a It is typically followed, on the next line by: foo Nothing = ... And if it isn't, and you use -Wall (you really should
by Peaker 13y ago
If you have:
foo (Just a) = bar a
It is typically followed, on the next line by:
foo Nothing = ...
And if it isn't, and you use -Wall (you really should!) you will get a warning for writing a partial function (which is sometimes warranted, but is a smell).
The function "fromJust" which is equivalent to "getValue" is very rarely useful, and considered a smell: making that one of the primary ways to use your Maybe value is a very bad idea.
if (isNothing (m))
{ .. }
else
{ .. m.getValue() .. }
Is much less safe than:
case m of
Nothing -> { .. }
Just val -> .. val ..
And has no useful advantage...