| Copyright | 2018 Automattic Inc. |
|---|---|
| License | BSD3 |
| Maintainer | Nathan Bloomfield (nbloomf@gmail.com) |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.MockIO.FileSystem
Description
A fake filesystem for testing.
- data FileSystem a = FileSystem [File a]
- data File a = File {
- _fileHandle :: a
- _fileContents :: [String]
- emptyFileSystem :: FileSystem a
- fileExists :: Eq a => a -> FileSystem a -> Bool
- hasFile :: Eq a => a -> [String] -> FileSystem a -> Bool
- deleteFile :: Eq a => a -> FileSystem a -> FileSystem a
- getLines :: Eq a => a -> FileSystem a -> Maybe [String]
- writeLines :: Eq a => a -> [String] -> FileSystem a -> FileSystem a
- appendLines :: Eq a => a -> [String] -> FileSystem a -> FileSystem a
- readLine :: Eq a => e -> e -> a -> FileSystem a -> Either e (String, FileSystem a)
Documentation
data FileSystem a Source #
A mapping from "handles" of type a to lists of lines.
Constructors
| FileSystem [File a] |
Abstraction of a text file consisting of a "handle" and a list of lines.
Constructors
| File | |
Fields
| |
emptyFileSystem :: FileSystem a Source #
No files; populate with writeLines or appendLines.
Arguments
| :: Eq a | |
| => a | File handle |
| -> FileSystem a | |
| -> Bool |
Detect whether a file with the given handle exists.
Arguments
| :: Eq a | |
| => a | Handle |
| -> [String] | Contents |
| -> FileSystem a | |
| -> Bool |
Detect whether a file with the given handle exists and has given contents.
Arguments
| :: Eq a | |
| => a | Handle |
| -> FileSystem a | |
| -> FileSystem a |
Delete a file; if no such file exists, has no effect.
Arguments
| :: Eq a | |
| => a | Handle |
| -> FileSystem a | |
| -> Maybe [String] |
Retrieve the contents of a file, or nothing if the file does not exist.
Arguments
| :: Eq a | |
| => a | Handle |
| -> [String] | Contents |
| -> FileSystem a | |
| -> FileSystem a |
Overwrite the contents of a file.
Arguments
| :: Eq a | |
| => a | Handle |
| -> [String] | Contents |
| -> FileSystem a | |
| -> FileSystem a |
Append to a file.
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.