Read and Write to Same File
kuq32tr02 at sneakemail.com
kuq32tr02 at sneakemail.com
Sun Oct 5 05:25:41 EDT 2003
I am writing a program that reads and writes to the same file. I was having some problems with it writing to the file before it read it. I solved it in the following two ways:
1.
main = do text <- readFile "test"
let something = somefunc text
writeFile "test2" something
renameFile "test2" "test"
2.
main = do text <- readFile "test"
let something = somefunc text
writeFile "test" $! something
Are both of these correct (guaranteed to give the behavior I want)? Which is better (and why)?
Thanks!
More information about the Haskell-Cafe
mailing list