4 ms·
Yeah, I just think that at every point in your program where you will have a Maybe the failure case could be as inelegant to program execution as raising an unc
by munin 13y ago
Yeah, I just think that at every point in your program where you will have a Maybe the failure case could be as inelegant to program execution as raising an uncaught NullPointerException, and escaping that involves a lot more work than using a language without a NullPointerException.
Maybe I should write more Haskell code, but this has definitely been my experience with OCaml...
- gizmo686 13y agoI've never used OCaml, but Haskell isn't as bad as you describe. When you use Maybe, you do not have to deal with the Nothing (ie. Null) case until you want to escape the monad (even then, you could still ignore it, and just crash if you do have Nothing). If an intermediate calculation results in Nothing, then the final value will be Nothing. Handling this is as simple as: foo :: Maybe Int -> Int foo Nothing = 0 foo (Just x) = x