Anyone care to explain why? I also tested a slightly changed program pasted below, and am very confused.
> main = do > -- This call doesn't terminate, why? > print $ nonTermination "a" > -- Comment the above line to test the rest of the code > -- RTS detects the loop and bails out > print $ process "abc" > -- Comment the above line to test the rest of the code > inp <- readFile "input" > -- I'm guessing (process inp) throws an exception, > -- and the handler closes all files, making a second close fail? > writeFile "output" $ process inp > process :: String -> String > process xs = blackhole where blackhole = tail blackhole > nonTermination :: String -> String > nonTermination _ = blackhole where blackhole = blackhole On Thu, Aug 12, 2010 at 3:38 PM, Simon Marlow <marlo...@gmail.com> wrote: > On 12/08/10 15:09, Yitzchak Gale wrote: >> >> 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) > > process xs = blackhole where blackhole = tail blackhole > > Cheers, > Simon > _______________________________________________ > 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