Why isEOF doesn't work?

时光毁灭记忆、已成空白 提交于 2019-12-06 11:19:00

From http://lambda.haskell.org/platform/doc/current/ghc-doc/libraries/haskell2010-1.1.1.0/System-IO.html#g:11:

NOTE: hIsEOF may block, because it has to attempt to read from the stream to determine whether there is any more data to be read.

The putStrLn doesn't affect the isEOF, but the isEOF prevents the program from getting to the putStrLn before more characters are available, or you have actually pressed ^D.

So you should never use hIsEOF/isEOF until the point in the program where you are ready to read more characters if there are any.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!