writeFile -package:yi-rope
The computation
writeFile file str function writes the
string
str, to the file
file.
This operation may fail with the same errors as
hPutStr and
withFile.
Examples
>>> writeFile "hello" "world" >> readFile "hello"
"world"
>>> writeFile "~/" "D:"
*** Exception: ~/: withFile: inappropriate type (Is a directory)
Write a string to a file. The file is truncated to zero length before
writing begins.
The computation
writeFile file str function writes the
string
str, to the file
file.
Write a series of
Strings as lines to a file.
>>> S.writeFile "lines.txt" $ S.take 2 S.stdinLn
hello<Enter>
world<Enter>
>>> S.readFile "lines.txt" S.stdoutLn
hello
world
Write lines to a file, automatically opening and closing the file as
necessary
Replace the entire content of a binary file with the provided
ByteString.
This computation throws
IOError on failure. See “Classifying
I/O errors” in the
System.IO.Error documentation for
information on why the failure occured.
Write
Chunks to a file, replacing the previous contents of the
file.
Write a
ByteStream to a file. Use
runResourceT to ensure
that the handle is closed.
>>> :set -XOverloadedStrings
>>> runResourceT $ Q.writeFile "hello.txt" "Hello world.\nGoodbye world.\n"
>>> :! cat "hello.txt"
Hello world.
Goodbye world.
>>> runResourceT $ Q.writeFile "hello2.txt" $ Q.readFile "hello.txt"
>>> :! cat hello2.txt
Hello world.
Goodbye world.
Write Text to a file. The file is truncated to zero length before
writing begins.