[Haskell-cafe] Use unsafePerformIO to catch Exception?

Benja Fallenstein benja.fallenstein at gmail.com
Wed Mar 25 21:56:55 EDT 2009


On Thu, Mar 26, 2009 at 2:40 AM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> I was not being precise when I said "tests for _|_". As you point out,
> the semantics of imprecise exceptions distinguishes exceptions from
> bottom, however pure code cannot make that distinction and so that's why
> I was lumping them together and saying that tryArith tests for certain
> kinds of _|_ value.

Right... I had this mental picture of exceptions being values
denotationally smaller than any "real" value of the domain before I
read the imprecise exceptions paper, so I interpreted your imprecise
description that way =)

> Anyway, I hope this is enough to dissuade people from using
> unsafePerformIO to catch exceptions.

Yes, unfortunately you can't even use it to return Nothing on errors
(ie without returning the specific exception) because of the (overflow
+ loop) issue where you have nondeterminism between returning Nothing
and looping forever. I have my own history of wondering "why isn't
there in Control.Exception a function that..." for a while before
figuring out why there isn't :-)

- Benja


More information about the Haskell-Cafe mailing list