stupid io question (haskell)
Jan. 14th, 2010 10:33 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
We had a discussion recently regarding this kind of code and how it should behave
Well, basically, no surprise; the moment the string started being scanned, there's already nothing there, so it does not print anything... somehow we were not sure about it, now I wonder why should we.
import System.IO
import Data.Char(toUpper)
main::IO()
main = do
h ← openFile "/vladp/haskell/testfile.txt" ReadMode
input ← hGetContents h
hClose h
let result = map toUpper input
putStr result
Well, basically, no surprise; the moment the string started being scanned, there's already nothing there, so it does not print anything... somehow we were not sure about it, now I wonder why should we.