On Thu, 27 Apr 2000 Jan Skibinski wrote:
> Since we are in a mood for puzzles today ..
>
> How to update file "xxx" without
> making backup "yyy" first, as in:
>
> readFile "xxx" >>=
> writeFile "yyy" >>=
> readFile "yyy" >>=
> process >>=
> writeFile "xxx"
> ?
I think, the problem can be solved by using the IO library and some strictness:
import IO
main = do text <- readFile "xxx"
text' <- process $! text
file <- openFile "xxx" WriteMode
hPutStr file text'
hClose file
seems to work. The file will be read completly befor it is re-opened for
writing.
Ralf Krueger
--
0---------------------------------0 In nur vier Zeilen was zu sagen
|[EMAIL PROTECTED]| erscheint zwar leicht, doch es ist schwer.
|[EMAIL PROTECTED] | Man braucht ja nur mal nachzuschlagen:
0---------------------------------0 Die meisten Dichter brauchen mehr. (H. E.)