safeio: Write output to disk atomically

[ io, library, mit ] [ Propose Tags ]

This package implements utilities to perform atomic output so as to avoid the problem of partial intermediate files.


[Skip to Readme]
Versions [faq] 0.0.1.0, 0.0.2.0, 0.0.3.0, 0.0.4.0, 0.0.5.0
Change log ChangeLog
Dependencies base (>4 && <5), directory, filepath, unix [details]
License MIT
Author Luis Pedro Coelho
Maintainer Luis Pedro Coelho
Category IO
Bug tracker https://github.com/luispedro/safeio/issues
Source repo head: git clone https://github.com/luispedro/safeio
Uploaded by luispedro at Mon May 29 15:10:13 UTC 2017
Distributions LTSHaskell:0.0.5.0, NixOS:0.0.5.0, Stackage:0.0.5.0
Downloads 1310 total (24 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-05-29 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for safeio-0.0.1.0

[back to package description]

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