3 ms·
Using getValue corresponds to extracting the value via pattern matching in Haskell. foo (Just a) = bar a For sure, Haskell has better syntax for this. ;)
by qznc 13y ago
Using getValue corresponds to extracting the value via pattern matching in Haskell.
foo (Just a) = bar a
For sure, Haskell has better syntax for this. ;)
- Peaker 13y agoIf 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...