Read and Write to Same File
Tomasz Zielonka
t.zielonka at students.mimuw.edu.pl
Sun Oct 5 12:37:16 EDT 2003
On Sun, Oct 05, 2003 at 04:25:41AM -0000, kuq32tr02 at sneakemail.com wrote:
> 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)?
There is no guarantee that $! will force evaluation of the entire
'something', so you can start writing to file before you finished
reading from it. Hopefully it will cause an exception (like in GHC),
otherwise you could damage your data (like in Hugs).
PS. How does it behave in NHC?
> Thanks!
Best regards,
Tom
--
.signature: Too many levels of symbolic links
More information about the Haskell-Cafe
mailing list