I get it that using Maybe prevents a null reference from crashing the program, but now you get a Nothing that's also unexpected. Is the philosophy then that you need to guard for Nothing or that it is just considered a lesser bug that needs to be fixed but at least doesn't kill the app. Or?
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
I get it that using Maybe prevents a null reference from crashing the program, but now you get a Nothing that's also unexpected. Is the philosophy then that you need to guard for Nothing or that it is just considered a lesser bug that needs to be fixed but at least doesn't kill the app. Or?
It changes from null being expected to. A Maybe being expected. So Nothing is a valid input.
When you use
map
, it will work on both aJust
and aNothing
.So you can stop guards completely!
This is a good example of what I am talking about:
You don't have to worry about if the value is a
Just
or aNothing
. You just accept aMaybe
.