
On Wed, Apr 22, 2009 at 2:49 AM, michael rice
How do I get the x out of Just x?
Hi Michael, in your code you're using Maybe to inform the caller of safeDivision about an exceptional situation. This way, you made a full coverage of all the input cases and nothing is left out, i.e. you created a total function (which is GOOD). If you introduced the Nothing case, you just don't want to ignore it. Also, the type system is forcing you to take the Nothing case into account so you can handle it properly. Hence, you might try something like the "maybe" function, which accounts for the Nothing case. If you'd use fromJust, the Nothing case would remain uncovered, leading you to an unhandled exception, which conflicts with your safeDivision definition. Cristiano