[Haskell-cafe] A GHC error message puzzle

Yitzchak Gale gale at sefer.org
Thu Aug 12 10:09:53 EDT 2010

The file "error_puzzle.hs" begins like this:

main = do
  inp <- readFile "input"
  writeFile "output" $ process inp

process :: String -> String

When compiled with GHC 6.12.3 and run, it
gives the following result:

$ ./error_puzzle
error_puzzle: output: hClose: illegal operation (handle is finalized)

What is the cause of the error? Give a definition
for process and an input file that reproduce this
result. No "unsafe" functions like unsafePerformIO
are allowed.

Have fun!

More information about the Haskell-Cafe mailing list