It makes sense, once you understand the terminology.

Thanks.

Michael

--- On Wed, 4/22/09, Cristiano Paris <frodo@theshire.org> wrote:

From: Cristiano Paris <frodo@theshire.org>
Subject: Re: [Haskell-cafe] Getting the x out
To: "michael rice" <nowgate@yahoo.com>
Cc: haskell-cafe@haskell.org
Date: Wednesday, April 22, 2009, 7:55 AM

On Wed, Apr 22, 2009 at 2:49 AM, michael rice <nowgate@yahoo.com> wrote:
> 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