[Haskell-cafe] Use unsafePerformIO to catch Exception?

Henning Thielemann lemming at henning-thielemann.de
Wed Mar 25 17:32:36 EDT 2009


On Wed, 25 Mar 2009, Jonathan Cast wrote:

> On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote:
>>
>> Could you elaborate more about why this kind of breakage
>> wouldn't happen if 'try' is used in an IO monad as intended?
>
> It would.  But it would happen in IO, which is allowed to be
> non-deterministic.  Pure Haskell is not allowed to be non-deterministic.

In my opinion, 'try' catching 'error's is still a hack, since 'error's aka 
bottom mean programming error. Thus catching them is debugging, bug hiding 
or something worse, but not exception handling. 'try' and friends should 
be limited to exceptional outcomes of IO actions, e.g. "disk full", "file 
read protected" etc. There might be a variant 'unsafeTry' which can also 
block 'error's.


More information about the Haskell-Cafe mailing list