script-monad-0.0.3: Stack of error, reader, writer, state, and prompt monad transformers

Copyright2018 Automattic Inc.
LicenseBSD3
MaintainerNathan Bloomfield (nbloomf@gmail.com)
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
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
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
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

-> [String]

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 [String] 

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

writeLines Source #

Arguments

:: Eq a 
=> a

Handle

-> [String]

Contents

-> FileSystem a 
-> FileSystem a 

Overwrite the contents of a file.

appendLines Source #

Arguments

:: Eq a 
=> a

Handle

-> [String]

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 (String, FileSystem a) 

Read the first line of a file.