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

Tillmann Rendel rendel at Mathematik.Uni-Marburg.de
Thu Aug 12 19:17:16 EDT 2010


the reading is not needed to make it happen.

   main = writeFile "output" blackhole where blackhole = blackhole

In fact, writing is not needed either.

   main = bracket
     (openFile "output" WriteMode)
     (\hdl -> blackhole `seq` return ())

   blackhole = blackhole

Note that writeFile is indeed like this, so this seems to be the same 

Sebastian Fischer wrote:
> Of course, the cause is the black hole. But why is it not reported?

I guess the following happens: When the blackhole is detected in the 
third argument of bracket, the second argument is executed. But for some 
reason, the handle is already finalized at this point, so hClose raises 
an exception itself. But bracket reraises the exception from its third 
argument only if its second argument does not raise an exception itself. 
So in this case, the "handle is finalized" exception seems to eat the 
"blackhole" exception.

So the question remains: Why is the handle finalized?

(And what is "finalizing an handle"?)


More information about the Haskell-Cafe mailing list