[Haskell-cafe] Re: A GHC error message puzzle

Tillmann Rendel rendel at Mathematik.Uni-Marburg.de
Sat Aug 14 18:05:42 EDT 2010


Simon Marlow wrote:
>>> Really hClose shouldn't complain about a finalized handle, I'll see if
>>> I can fix that.
>>
>> That sounds like a work-around to me, not a fix, because it would not
>> fix more complicated exception handlers.
> 
> I don't think there's a problem with more complicated exception 
> handlers.  The fix is to make the finalized Handle look like a closed 
> Handle; it's a fix to the finalizer, not the exception handler, so it's 
> not a workaround for this one particular symptom.

Given the documentation of bracket, I would expect the following to 
write to the file.

   main = bracket
     (openFile "output" WriteMode)
     (\handle -> do
       hPutStr handle "I want this to be written in any case"
       hClose handle)
     blackhole

   blackhole = blackhole

But currently, hPutStr complains about a finalized handle, and with your 
fix, it would complain about a closed handle, which is hardly better.

   Tillmann


More information about the Haskell-Cafe mailing list