
Francesco:
Unfortunately, using withFile I get the same error as before with handles:
hPutStr: illegal operation (handle is closed).
Any other suggestions for reading and writing to the same file in the same
function?
Thanks
On Thu, Feb 5, 2015 at 3:26 PM, Francesco Ariis
On Thu, Feb 05, 2015 at 02:51:52PM -0500, Geoffrey Bays wrote:
As I work my way through Learn You as Haskell, I have been writing small File IO programs. Unlike the example in that book, where the author reads from one file, writes altered data to a temp file and then deletes the original file and renames the temp file, I have been trying to read from a given file, alter the data and then overwrite the same file with the new data. Is this possible?
Try `withFile` [1], there is an example of its usage in chapter 9 of LYAH [2].
[1] https://downloads.haskell.org/~ghc/6.12.2/docs/html/libraries/base-4.2.0.1/S... [2] http://learnyouahaskell.com/input-and-output#files-and-streams _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners