Safe Haskell | None |
---|---|
Language | Haskell2010 |
This is intended to demonstrate how a VFS can be defined, but is also entirely usable in code if you find its functionality useful.
This VFS implementation stores its values in a lazy in-memory map, which is itself persisted into an MVar
and captured in the monadic state.
This requires the monad to be in the class MonadUnliftIO
, but that allows the state to be shared throughout the application, maintaining
value consistency across threads and even across invocations.
Individual read and write operations are atomic.
The FilePath
values used in this VFS are split using splitPath
and joined using </>
, but are otherwise used directly: there is no concept of
paths being "relative" or "absolute" for this VFS. It is also possible for a file and a directory to have the same name, since directories names
are appended with /
, as per splitPath
. (This implementation detail is up for debate and may be changed in a future major release: please file
an issue if you want to have a discussion around it.)
Synopsis
- data InMemoryVFS m a
- data InMemoryVFSRoot
- runInMemoryVFS :: MonadUnliftIO m => InMemoryVFS m a -> m a
- runInMemoryVFS' :: InMemoryVFSRoot -> InMemoryVFS m a -> m a
- mkInMemoryVFSRoot :: MonadIO m => m InMemoryVFSRoot
Documentation
data InMemoryVFS m a Source #
The basic implementation of the VFS.
Instances
data InMemoryVFSRoot Source #
The root of the VFS.
Instances
Monad m => MonadReader InMemoryVFSRoot (InMemoryVFS m) Source # | |
Defined in Data.Conduit.VFS.InMemory ask :: InMemoryVFS m InMemoryVFSRoot # local :: (InMemoryVFSRoot -> InMemoryVFSRoot) -> InMemoryVFS m a -> InMemoryVFS m a # reader :: (InMemoryVFSRoot -> a) -> InMemoryVFS m a # |
runInMemoryVFS :: MonadUnliftIO m => InMemoryVFS m a -> m a Source #
Given an InMemoryVFS
, run it in the local monad.
runInMemoryVFS' :: InMemoryVFSRoot -> InMemoryVFS m a -> m a Source #
Runs an InMemoryVFS
using a provided InMemoryVFSRoot
.
mkInMemoryVFSRoot :: MonadIO m => m InMemoryVFSRoot Source #
Creates an InMemoryVFSRoot
that can be shared among many InMemoryVFS
invocations.