[Haskell-beginners] Buggy behavior of "withFile"
Zoran Plesivčak
zplesiv at gmail.com
Tue Dec 9 20:21:52 UTC 2014
I've encountered unexplainable of "withFile" function. Consider
"example.hs" program:
import System.IO
main = do
cnts <- withFile "example.hs" ReadMode $ (\h -> do
res <- hGetContents h
--putStr res
return res)
putStr cnts
When commented-out line is like that, program doesn't write out
anything to the STDOUT.
If "--" (commend characters) are removed, program writes out contents
of "example.hs" two times.
Is this expected behavior? I asked on #haskell (freenode) and one
fellow there found it equally confusing...
-------------------------------------------
GHC version: The Glorious Glasgow Haskell Compilation System, version 7.6.3
OS: Linux
Thanks,
Zoran Plesivčak
More information about the Beginners
mailing list