Ralf and Sven:
Thank you both for your answers. I knew that strictness
was needed here, but I was seeking some elegant solution.
I prefer your answer, Sven, a bit more. Could you elaborate
on your `hack' a bit more? It seems to be a good topic for
"how to be strict".
Your dressed up, reusable version is attached below.
Jan
--------------------------------------------------------
updateFile :: FilePath -> (String -> IO String) -> IO ()
updateFile file process
--
-- `process' content of `file'
-- and update it in place
--
= readFile file >>=
hyperHack >>=
process >>=
writeFile file
where
hyperHack txt
| length txt >= 0 = return txt
| otherwise = error "never happens"
-------------------------------------------------------