hashed-storage-0.3.5: Hashed file storage support code.Source codeContentsIndex
Storage.Hashed.Monad
Description
An experimental monadic interface to Tree mutation. The main idea is to simulate IO-ish manipulation of real filesystem (that's the state part of the monad), and to keep memory usage down by reasonably often dumping the intermediate data to disk and forgetting it. XXX This currently does not work as advertised and the monads leak memory. So far, I'm at a loss why this happens.
Synopsis
hashedTreeIO :: TreeIO a -> Tree -> FilePath -> IO (a, Tree)
plainTreeIO :: TreeIO a -> Tree -> FilePath -> IO (a, Tree)
virtualTreeIO :: TreeIO a -> Tree -> IO (a, Tree)
readFile :: AnchoredPath -> TreeIO ByteString
writeFile :: AnchoredPath -> ByteString -> TreeIO ()
createDirectory :: AnchoredPath -> TreeIO ()
rename :: AnchoredPath -> AnchoredPath -> TreeIO ()
unlink :: AnchoredPath -> TreeIO ()
fileExists :: AnchoredPath -> TreeIO Bool
exists :: AnchoredPath -> TreeIO Bool
tree :: TreeState -> Tree
cwd :: TreeState -> AnchoredPath
data TreeState
type TreeIO = StateT TreeState IO
Documentation
hashedTreeIOSource
::
=> TreeIO aaction
-> Treeinitial
-> FilePathdirectory
-> IO (a, Tree)

Run a TreeIO action in a hashed setting. The initial tree is assumed to be fully available from the directory, and any changes will be written out to same. Please note that actual filesystem files are never removed.

XXX This somehow manages to leak memory, somewhere.

plainTreeIO :: TreeIO a -> Tree -> FilePath -> IO (a, Tree)Source
Run a TreeIO action in a plain tree setting. Writes out changes to the plain tree every now and then (after the action is finished, the last tree state is always flushed to disk). XXX Modify the tree with filesystem reading and put it back into st (ie. replace the in-memory Blobs with normal ones, so the memory can be GCd).
virtualTreeIO :: TreeIO a -> Tree -> IO (a, Tree)Source
Run a TreeIO action without dumping anything to disk. Useful for running tree mutations just for the purpose of getting the resulting Tree and throwing it away.
readFile :: AnchoredPath -> TreeIO ByteStringSource
Grab content of a file in the current Tree at the given path.
writeFile :: AnchoredPath -> ByteString -> TreeIO ()Source
Change content of a file at a given path. The change will be eventually flushed to disk, but might be buffered for some time.
createDirectory :: AnchoredPath -> TreeIO ()Source
rename :: AnchoredPath -> AnchoredPath -> TreeIO ()Source
unlink :: AnchoredPath -> TreeIO ()Source
fileExists :: AnchoredPath -> TreeIO BoolSource
Check for existence of a file.
exists :: AnchoredPath -> TreeIO BoolSource
Check for existence of a node (file or directory, doesn't matter).
tree :: TreeState -> TreeSource
cwd :: TreeState -> AnchoredPathSource
data TreeState Source
Internal state of the TreeIO monad. Keeps track of the current Tree content, unsync'd changes and a current working directory (of the monad).
type TreeIO = StateT TreeState IOSource
A TreeIO monad. A sort of like IO but it keeps a TreeState around as well, which is a sort of virtual filesystem. Depending on how you obtained your TreeIO, the actions in your virtual filesystem get somehow reflected in the actual real filesystem. For virtualTreeIO, nothing happens in real filesystem, however with plainTreeIO, the plain tree will be updated every now and then, and with hashedTreeIO a darcs-style hashed tree will get updated.
Produced by Haddock version 2.4.2