
The idea is that if you want to use Exceptions in their full glory, you: ... import qualified Exception
I've noticed something a bit unusual about Exception.catch. It seems it can't catch "return undefined" by itself. Consider these values of type "IO String":
iouPure :: IO String; iouPure = undefined;
iouError :: IO String; iouError = error "error";
These aren't even an IO actions, they're simply bottom. Straightforward enough. But they _will_ be caught by Exception.catch.
iouFail :: IO String; iouFail = fail "failure";
iouEvaluate :: IOString; iouEvaluate = Exception.evaluate undefined;
These two are IO actions that "fail" when executed. They will also be caught by Exception.catch.
iouReturn :: IO String; iouReturn = return undefined;
This one is an IO action that "succeeds" when executing. It _won't_ be caught by Exception.catch, which will instead simply return the undefined value.
I'm not sure what to make of this...
This is just an artifact of the laziness of 'return'. One of the monad laws is return a >>= k = k a so therefore return undefined >>= (\_ -> m) = m so return can't be strict. Since return isn't strict, return undefined `seq` a = a So that's really why we have Exception.evaluate: it's a strict version of return. Cheers, Simon