script-monad-0.0.4: Stack of error, reader, writer, state, and prompt monad transformers
Copyright2018 Automattic Inc.
LicenseBSD3
MaintainerNathan Bloomfield (nbloomf@gmail.com)
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.MockIO.FileSystem

Description

A fake filesystem for testing.

Synopsis

Documentation

data FileSystem a Source #

A mapping from "handles" of type a to lists of lines.

Constructors

FileSystem [File a] 

Instances

Instances details
Eq a => Eq (FileSystem a) Source # 
Instance details

Defined in Data.MockIO.FileSystem

Methods

(==) :: FileSystem a -> FileSystem a -> Bool #

(/=) :: FileSystem a -> FileSystem a -> Bool #

Show a => Show (FileSystem a) Source # 
Instance details

Defined in Data.MockIO.FileSystem

(Eq a, Arbitrary a) => Arbitrary (FileSystem a) Source # 
Instance details

Defined in Data.MockIO.FileSystem

data File a Source #

Abstraction of a text file consisting of a "handle" and a list of lines.

Constructors

File 

Fields

Instances

Instances details
Eq a => Eq (File a) Source # 
Instance details

Defined in Data.MockIO.FileSystem

Methods

(==) :: File a -> File a -> Bool #

(/=) :: File a -> File a -> Bool #

Show a => Show (File a) Source # 
Instance details

Defined in Data.MockIO.FileSystem

Methods

showsPrec :: Int -> File a -> ShowS #

show :: File a -> String #

showList :: [File a] -> ShowS #

emptyFileSystem :: FileSystem a Source #

No files; populate with writeLines or appendLines.

fileExists Source #

Arguments

:: Eq a 
=> a

File handle

-> FileSystem a 
-> Bool 

Detect whether a file with the given handle exists.

hasFile Source #

Arguments

:: Eq a 
=> a

Handle

-> [Text]

Contents

-> FileSystem a 
-> Bool 

Detect whether a file with the given handle exists and has given contents.

deleteFile Source #

Arguments

:: Eq a 
=> a

Handle

-> FileSystem a 
-> FileSystem a 

Delete a file; if no such file exists, has no effect.

getLines Source #

Arguments

:: Eq a 
=> a

Handle

-> FileSystem a 
-> Maybe [Text] 

Retrieve the contents of a file, or nothing if the file does not exist.

writeLines Source #

Arguments

:: Eq a 
=> a

Handle

-> [Text]

Contents

-> FileSystem a 
-> FileSystem a 

Overwrite the contents of a file.

appendLines Source #

Arguments

:: Eq a 
=> a

Handle

-> [Text]

Contents

-> FileSystem a 
-> FileSystem a 

Append to a file.

readLine Source #

Arguments

:: Eq a 
=> e

Handle not found error

-> e

EOF error

-> a

Handle

-> FileSystem a 
-> Either e (Text, FileSystem a) 

Read the first line of a file.