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.
Synopsis
- 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.
FileSystem [File a] |
Instances
Eq a => Eq (FileSystem a) Source # | |
Defined in Data.MockIO.FileSystem (==) :: FileSystem a -> FileSystem a -> Bool # (/=) :: FileSystem a -> FileSystem a -> Bool # | |
Show a => Show (FileSystem a) Source # | |
Defined in Data.MockIO.FileSystem 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 arbitrary :: Gen (FileSystem a) # shrink :: FileSystem a -> [FileSystem a] # |
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.