[Haskell-cafe] Use unsafePerformIO to catch Exception?
jake.mcarthur at gmail.com
Wed Mar 25 02:24:06 EDT 2009
Donn Cave wrote:
> Could you elaborate a little, in what sense are we (?) relying on it?
> I actually can't find any responses that make a case against it on a
> really practical level - I mean, it seems to be taken for granted that
> it will work as intended, and we're down to whether we ought to have
> such intentions, as a matter of principle. If you've identified a
> problem here with semantics that would break normal evaluation, from
> the perspective of the programmer's intention, then this would be
> the first practical reason?
Off the top of my head, here is a possible case:
foo :: Int -> Int
foo x = ... -- something that might throw an exception
bar :: Int -> Blah
bar x = ... -- internally use foo and catch the exception
baz :: Int -> Blah
baz = bar . foo
In this case, if the foo in baz throws an exception, I think bar may
catch it and attempt to handle it as if the foo in bar had thrown it,
but we probably would have expected this exception to go all the way to
the top level and halt the program since exceptions are usually due to
But I didn't test this, and since this isn't something I've ever done
before I can't be 100% sure of its behavior.
More information about the Haskell-Cafe