Copyright | 2018 Automattic Inc. |
---|---|
License | BSD3 |
Maintainer | Nathan Bloomfield (nbloomf@gmail.com) |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe |
Language | Haskell2010 |
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
Abstraction of a text file consisting of a "handle" and a list of lines.
File | |
|
emptyFileSystem :: FileSystem a Source #
No files; populate with writeLines
or appendLines
.
:: Eq a | |
=> a | File handle |
-> FileSystem a | |
-> Bool |
Detect whether a file with the given handle exists.
:: Eq a | |
=> a | Handle |
-> [String] | Contents |
-> FileSystem a | |
-> Bool |
Detect whether a file with the given handle exists and has given contents.
:: Eq a | |
=> a | Handle |
-> FileSystem a | |
-> FileSystem a |
Delete a file; if no such file exists, has no effect.
:: Eq a | |
=> a | Handle |
-> FileSystem a | |
-> Maybe [String] |
Retrieve the contents of a file, or nothing if the file does not exist.
:: Eq a | |
=> a | Handle |
-> [String] | Contents |
-> FileSystem a | |
-> FileSystem a |
Overwrite the contents of a file.
:: Eq a | |
=> a | Handle |
-> [String] | Contents |
-> FileSystem a | |
-> FileSystem a |
Append to a file.
:: 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.