import IO main = do hdl <- openFile "/tmp/foo.txt" WriteMode hPutStr hdl "Hello," hFlush hdl hPutStr hdl "world!" hFlush hdl hClose hdl hdl <- openFile "/tmp/foo.txt" ReadMode x <- hGetContents hdl putStr x hClose hdl