[Haskell] Re: [Haskell - I/O] Problem with 'readFile'

Benjamin Franksen benjamin.franksen at bessy.de
Sat Aug 26 19:11:21 EDT 2006

L. J. wrote:

>  Hi, I use the operation 'readFile' for obtain information locates on
> a file. When I try to write another information on the same file, I
> obtain this error message: "openFile: permision denied". I found this:
> "The readFile operation holds a semi-closed handle on the file until
> the entire contents of the file have been consumed. It follows that an
> attempt to write to a file (using writeFile, for example) that was
> earlier opened by readFile will usually result in failure with
> isAlreadyInUseError." in this web
> http://www.haskell.org/onlinereport/io.html.
>  How can I break that semi-closed handle for to write in the
> preaviously readed file? Thank you.

Since readFile reads the file lazily (on demand), you have to make sure that
the whole file gets read by completely evaluating the result string.

BTW, I think haskell-cafe is the more appropriate forum for questions like


More information about the Haskell mailing list