Hi,

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)
    hClose
    (\hdl -> blackhole `seq` return ())

  blackhole = blackhole

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

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"?)

  Tillmann
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to