| Copyright | 2018 Automattic Inc. |
|---|---|
| License | BSD3 |
| Maintainer | Nathan Bloomfield ([email protected]) |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.MockIO.FileSystem
Description
A fake filesystem for testing.
Synopsis
- data FileSystem a = FileSystem [File a]
- data File a = File {
- _fileHandle :: a
- _fileContents :: [Text]
- emptyFileSystem :: FileSystem a
- fileExists :: Eq a => a -> FileSystem a -> Bool
- hasFile :: Eq a => a -> [Text] -> FileSystem a -> Bool
- deleteFile :: Eq a => a -> FileSystem a -> FileSystem a
- getLines :: Eq a => a -> FileSystem a -> Maybe [Text]
- writeLines :: Eq a => a -> [Text] -> FileSystem a -> FileSystem a
- appendLines :: Eq a => a -> [Text] -> FileSystem a -> FileSystem a
- readLine :: Eq a => e -> e -> a -> FileSystem a -> Either e (Text, FileSystem a)
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 # | |
Defined in Data.MockIO.FileSystem | |
| Show a => Show (FileSystem a) Source # | |
Defined in Data.MockIO.FileSystem Methods showsPrec :: Int -> FileSystem a -> ShowS # show :: FileSystem a -> String # showList :: [FileSystem a] -> ShowS # | |
| (Eq a, Arbitrary a) => Arbitrary (FileSystem a) Source # | |
Defined in Data.MockIO.FileSystem | |
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 |
| -> [Text] | 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 [Text] |
Retrieve the contents of a file, or nothing if the file does not exist.
Arguments
| :: Eq a | |
| => a | Handle |
| -> [Text] | Contents |
| -> FileSystem a | |
| -> FileSystem a |
Overwrite the contents of a file.
Arguments
| :: Eq a | |
| => a | Handle |
| -> [Text] | 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 (Text, FileSystem a) |
Read the first line of a file.