Read and Write to Same File

kuq32tr02 at kuq32tr02 at
Sun Oct 5 17:20:12 EDT 2003

> > main = do text <- readFile "test"
> >           let something = somefunc text
> >           writeFile "test" $! something
> 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?

This is the version I've been using for a while now.  It runs perfectly fine in both GHC and Hugs.  I've used it many, many times with no noticeable problems.  Should I be seeing errors (like exceptions in GHC)?

I don't have NHC installed, so I can't test it.


More information about the Haskell-Cafe mailing list