[Haskell-cafe] A GHC error message puzzle

Pierre-Etienne Meunier pierreetienne.meunier at gmail.com
Thu Aug 12 11:47:20 EDT 2010


readFile is lazy IO, so the unsafePerformIO or equivalents are already there.

It should be enough to invent a strict process function, but which ghc 6.12.3 isn't able to figure out that it is strict. Does it still work with :

writeFile "output" $! process inp

This raises another question : the strictness analysis is undecidable, but do we know of an explicit sequence of functions, strict in their argument, which ghc will always fail in recognizing that they are strict ? (we need an infinite sequence, because ghc could be programed to recognize a specific function each time, of course).


El 12/08/2010, a las 10:09, Yitzchak Gale escribió:

> 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!
> -Yitz
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list