@hackage safeio0.0.1.0

Write output to disk atomically

SafeIO: Haskell library for safe (atomic) IO

This is a simple module, which enables writing in atomic mode. It implements the following 4 step procedure:

  1. Open a temporary file in the same directory as the final output.
  2. Write to this temporary file.
  3. Close and sync the file.
  4. Atomically rename the file to its final destination.

Example

import System.IO.SafeWrite
...
main = do
    withOutputFile "output.txt" $ \hout -> do
        hPutStrLn hout "Hello World"

Author

Luis Pedro Coelho Email