|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. The monad interface itself is
generic, and a number of actual implementations can be used. This module
provides just virtualTreeIO that never writes any changes, but may trigger
filesystem reads as appropriate.
|virtualTreeIO :: TreeIO a -> Tree IO -> IO (a, Tree IO)|
|virtualTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> Tree m -> m (a, Tree m)|
|readFile :: TreeRO m => Relative -> m ByteString|
|writeFile :: TreeRW m => Relative -> ByteString -> m ()|
|createDirectory :: TreeRW m => Relative -> m ()|
|rename :: TreeRW m => Relative -> Relative -> m ()|
|copy :: TreeRW m => Relative -> Relative -> m ()|
|unlink :: TreeRW m => Relative -> m ()|
|fileExists :: TreeRO m => Relative -> m Bool|
|directoryExists :: TreeRO m => Relative -> m Bool|
|exists :: TreeRO m => Relative -> m Bool|
|existsAnycase :: (Functor m, Monad m) => Relative -> TreeMonad m Bool|
|withDirectory :: TreeRO m => Relative -> m a -> m a|
|currentDirectory :: TreeRO m => m Relative|
|currentTree :: Monad m => TreeMonad m (Tree m)|
|data TreeState m|
|type TreeMonad m = RWST Relative () (TreeState m) m|
|type TreeIO = TreeMonad IO|
|runTreeMonad :: (Functor m, Monad m) => TreeMonad m a -> TreeState m -> m (a, Tree m)|
|initialState :: Tree m -> (TreeItem m -> m Hash) -> (Relative -> TreeItem m -> TreeMonad m (TreeItem m)) -> TreeState m|
|replaceItem :: (Functor m, Monad m) => Relative -> Maybe (TreeItem m) -> TreeMonad m ()|
|findM :: (Monad m, Functor m) => Tree m -> Relative -> m (Maybe (TreeItem m))|
|findTreeM :: (Monad m, Functor m) => Tree m -> Relative -> m (Maybe (Tree m))|
|findFileM :: (Monad m, Functor m) => Tree m -> Relative -> m (Maybe (Blob m))|
|Run a TreeIO action without storing any changes. This is useful for
running monadic tree mutations for obtaining the resulting Tree (as opposed
to their effect of writing a modified tree to disk). The actions can do both
read and write -- reads are passed through to the actual filesystem, but the
writes are held in memory in a form of modified Tree.
|Grab content of a file in the current Tree at the given path.
|Change content of a file at a given path. The change will be
eventually flushed to disk, but might be buffered for some time.
|Check for existence of a file.
|Check for existence of a directory.
|Check for existence of a node (file or directory, doesn't matter).
|Internal state of the TreeIO monad. Keeps track of the current Tree
content, unsync'd changes and a current working directory (of the monad).
|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
|Replace an item with a new version without modifying the content of the
tree. This does not do any change tracking. Ought to be only used from a
sync implementation for a particular storage format. The presumed use-case
is that an existing in-memory Blob is replaced with a one referring to an
|Produced by Haddock version 2.6.0|