Prelude.catch vs. Exception.catch

Ashley Yakeley
Tue, 14 May 2002 03:23:10 -0700

At 2002-05-14 02:58, Simon Marlow wrote:

>I must admit I can't think of any compelling reasons for the change,
>other than the fact that this is functionality that we don't have at the
>moment, and therefore might be useful.  Opinions?

I need a function that does this:

    evaluate :: a -> IO a
    evaluate _|_ = fail something
    evaluate a = return a

The idea is that you can take something that might be bottom and safely 
handle it in the IO monad, with the "bottomness" gone. This is what 
Exception.evaluate currently does, and I think that's correct.

I think the behaviour of Exception.catch is wrong. I think it should 
behave like this:

    catch _|_ cc = _|_
    catch (failure ex) cc = cc ex
    catch (success a) cc = success a

...whereas it actually behaves like this:

    catch _|_ cc = cc something
    catch (failure ex) cc = cc ex
    catch (success a) cc = success a

Ashley Yakeley, Seattle WA