appendFile

The computation appendFile file str function appends the string str, to the file file. Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first. This operation may fail with the same errors as hPutStr and withFile.

Examples

The following example could be more efficently written by acquiring a handle instead with openFile and using the computations capable of writing to handles such as hPutStr.
>>> let fn = "hello_world"

>>> in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn)
"hello world!"
>>> let fn = "foo"; output = readFile' fn >>= putStrLn

>>> in output >> appendFile fn (show [1,2,3]) >> output
this is what's in the file
this is what's in the file[1,2,3]
Append a ByteString to a file.
Write a string to the end of a file.
The computation appendFile file str function appends the string str, to the file file. Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first.
main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
Lifted version of appendFile.
Lifted appendFile
Lifted appendFile
Append a ByteString to a file. If the file does not exist, it will be created. This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.
Append a Text to a file.
Append a ByteStream to a file. Use runResourceT to ensure that the handle is closed.
>>> runResourceT $ Q.writeFile "hello.txt" "Hello world.\nGoodbye world.\n"

>>> runResourceT $ Q.stdout $ Q.readFile "hello.txt"
Hello world.
Goodbye world.

>>> runResourceT $ Q.appendFile "hello.txt" "sincerely yours,\nArthur\n"

>>> runResourceT $ Q.stdout $  Q.readFile "hello.txt"
Hello world.
Goodbye world.
sincerely yours,
Arthur
Append data to file.
Write Text to the end of a file.
Append a Vector to a file.
Lifted version of appendFile.
The computation appendFile file str function appends the lazy ByteString str, to the file file.
Like appendFile, but takes a PlatformPath instead of an OsPath.
Write a string to the end of a file The default definition uses withFile to open the file.
Append a ByteString to a file at the RawFilePath.