ouroboros-consensus-test-0.1.0.0: Tests of the consensus layer
Safe HaskellNone
LanguageHaskell2010

Test.Util.FS.Sim.FsTree

Description

Internal part of the mock file system

Intended for qualified import

import Test.Util.FS.Sim.FsTree (FsTree)
import Test.Util.FS.Sim.FsTree as FS
Synopsis

FsTree type and indexing functions

data FsTree a Source #

Simple in-memory representation of a file system

Constructors

File !a 
Folder !(Folder a) 

Instances

Instances details
Functor FsTree Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

Methods

fmap ∷ (a → b) → FsTree a → FsTree b Source #

(<$) ∷ a → FsTree b → FsTree a Source #

Eq a ⇒ Eq (FsTree a) Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

Methods

(==)FsTree a → FsTree a → Bool Source #

(/=)FsTree a → FsTree a → Bool Source #

Show a ⇒ Show (FsTree a) Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

Methods

showsPrecIntFsTree a → ShowS Source #

showFsTree a → String Source #

showList ∷ [FsTree a] → ShowS Source #

Generic (FsTree a) Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

Associated Types

type Rep (FsTree a) ∷ TypeType Source #

Methods

fromFsTree a → Rep (FsTree a) x Source #

toRep (FsTree a) x → FsTree a Source #

NoThunks a ⇒ NoThunks (FsTree a) Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

Methods

noThunks ∷ Context → FsTree a → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → FsTree a → IO (Maybe ThunkInfo) #

showTypeOfProxy (FsTree a) → String #

type Rep (FsTree a) Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

type Rep (FsTree a)

data FsTreeError Source #

File access error

Constructors

FsExpectedDir FsPath (NonEmpty Text)

A path ..a.. where a is a file rather than a dir

We record both the full path and the invalid suffix.

FsExpectedFile FsPath

A path ..a.. where a is a dir rather than a file

No suffix is specified (it must be the last part of the file)

FsMissing FsPath (NonEmpty Text)

A path ..a.. or ../a where directory or file a is missing

We record both the full path and the missing suffix.

FsExists FsPath

A file was opened with the O_EXCL flag, but it already existed.

Instances

Instances details
Show FsTreeError Source # 
Instance details

Defined in Test.Util.FS.Sim.FsTree

exampleMonoid a ⇒ FsTree a Source #

Example

Construction

Indexing

getDirFsPathFsTree a → Either FsTreeError (Folder a) Source #

indexFsPathFsTree a → Either FsTreeError (FsTree a) Source #

Index the FsTree by the given FsPath.

File system operations

createDirIfMissingFsPathFsTree a → Either FsTreeError (FsTree a) Source #

Create a directory if it does not already exist

createDirWithParentsFsPathFsTree a → Either FsTreeError (FsTree a) Source #

Create a directory and its parents if they do not already exist

openFileMonoid a ⇒ FsPathAllowExistingFsTree a → Either FsTreeError (FsTree a) Source #

Open a file: create it if necessary or throw an error if it existed already wile we were supposed to create it from scratch (when passed MustBeNew).

removeFileFsPathFsTree a → Either FsTreeError (FsTree a) Source #

Remove a file (which must exist)

renameFileFsPathFsPathFsTree a → Either FsTreeError (FsTree a) Source #

Rename the file (which must exist) from the first path to the second path. If there is already a file at the latter path, it is replaced by the new one.

replaceFsPath → a → FsTree a → Either FsTreeError (FsTree a) Source #

Replace the contents of the specified file (which must exist)

Pretty-printing

pretty ∷ ∀ a. (a → String) → FsTree a → String Source #