@hackage fs-api0.4.0.0
Abstract interface for the file system
Categories
License
Apache-2.0
Maintainer
operations@iohk.io, Joris Dral (joris@well-typed.com)
Links
Versions
Installation
Dependencies (14)
- Win32 ^>=2.14
- base >=4.16 && <4.23
- bytestring ^>=0.10 || ^>=0.11 || ^>=0.12
- containers ^>=0.5 || ^>=0.6 || ^>=0.7 || ^>=0.8
- deepseq ^>=1.4 || ^>=1.5
- digest ^>=0.0 Show all…
Dependents (3)
@hackage/fs-sim, @hackage/blockio, @hackage/lsm-tree
fs-api
The fs-api package provides an abstract interface to filesystems. The abstract
interface is a datatype called HasFS, which is parameterised over a monad m
that filesystem operations run in, and the type of file handles h.
removeFile is an example of a filesystem operation in this interface.
data HasFS m h = HasFS {
{- omitted -}
-- | Remove the file (which must exist)
, removeFile :: HasCallStack => FsPath -> m ()
{- omitted -}
}
Code that is written using this interface can be run against any implementation
of a file system. The System.FS.IO module provides a function for initialising
a HasFS interface for the real filesystem.
ioHasFS :: (MonadIO m, PrimState IO ~ PrimState m) => MountPoint -> HasFS m HandleIO
Note that ioHasFS requires some context in the form of a MountPoint: the
base directory in which the filesystem operations should be run.