2
我想獲得一個程序來讀取整個文件使用hFlush,以避免我遇到的問題與懶惰的IO有關。haskell hFlush不工作的方式我期待
readHandle <- openFile fileName ReadMode
hSetBuffering readHandle $ BlockBuffering (Just 2048)
fileText <- hGetContents readHandle
hFlush readHandle
hClose readHandle
這只是給我的錯誤:hFlush:非法操作(關閉句柄)
能有人幫助我瞭解什麼是對
見http://stackoverflow.com/questions/5373883/haskell-laziness-how-do-i-force-the-io-to-happen-sooner?rq=1 –
還,'hFlush'刷新_output_緩衝區。首先在只讀句柄上使用它沒有任何意義。 – hammar
我推薦使用'System.IO.Strict'中的'hGetContents',並避免使用懶惰IO。 –