fs-api: Abstract interface for the file system

[ apache, library, system ] [ Propose Tags ] [ Report a vulnerability ]

Abstract interface for the file system.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.3.0.0, 0.3.0.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <4.21), bytestring (>=0.10 && <0.13), containers (>=0.5 && <0.8), deepseq (>=1.4 && <1.6), digest (>=0.0 && <0.1), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), io-classes (>=1.6 && <1.8), primitive (>=0.9 && <0.10), safe-wild-cards (>=1.0 && <1.1), text (>=1.2 && <1.3 || >=2.0 && <2.2), unix (>=2.7 && <2.9), unix-bytestring (>=0.4 && <0.5), Win32 (>=2.6.1.0) [details]
Tested with ghc ==8.10 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10
License Apache-2.0[multiple license files]
Copyright 2019-2024 Input Output Global Inc (IOG)
Author IOG Engineering Team
Maintainer operations@iohk.io, Joris Dral (joris@well-typed.com)
Category System
Home page https://github.com/input-output-hk/fs-sim
Bug tracker https://github.com/input-output-hk/fs-sim/issues
Source repo head: git clone https://github.com/input-output-hk/fs-sim(fs-api)
Uploaded by jdral at 2024-10-02T10:41:18Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 328 total (132 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-10-02 [all 1 reports]

Readme for fs-api-0.3.0.1

[back to package description]

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.