[Haskell-cafe] A GHC error message puzzle
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A GHC error message puzzle
Hi, 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). PE 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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A GHC error message puzzle
Give a definition for process and an input file that reproduce this result. Quite probably not the intended solution: process :: String - String process _ = error output: hClose: illegal operation (handle is finalized) Have fun! Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A GHC error message puzzle
Sebastian Fischer wrote: process _ = error output: hClose: illegal operation (handle is finalized) Haha, very good! But I'm thinking of a case where GHC really does print out the error message. -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A GHC error message puzzle
Pierre-Etienne Meunier wrote: Does it still work with : writeFile output $! process inp You're right, that changes things. Then the program prints: loop That would have given it away, of course. :) Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A GHC error message puzzle
When I tried this it never returned, there was no error. -deech On Thu, Aug 12, 2010 at 4:04 PM, Yitzchak Gale g...@sefer.org wrote: Pierre-Etienne Meunier wrote: Does it still work with : writeFile output $! process inp You're right, that changes things. Then the program prints: loop That would have given it away, of course. :) Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe