Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- File-operations.
- type SearchPath = [FilePath]
- type LocatedData a = (FilePath, a)
- locate :: FilePath -> SearchPath -> IO [FilePath]
- getFile :: FilePath -> SearchPath -> IO (LocatedData String)
- fromFile :: Read a => FilePath -> SearchPath -> IO (LocatedData a)
- getFilePath :: LocatedData a -> FilePath
- getData :: LocatedData a -> a
Types
Type-synonyms
type SearchPath = [FilePath] Source #
The ordered sequence of directories, searched for a file.
type LocatedData a = (FilePath, a) Source #
A file-path, and the contents read from it.
Functions
locate :: FilePath -> SearchPath -> IO [FilePath] Source #
- When supplied with an absolute file-path, the search-path is ignored and an exception is thrown if either the file-path is invalid or the file doesn't exist.
- If the specified file-name is relative, all matching instances on the specified search-path are returned.
- CAVEAT: doesn't perform file-globbing.
getFile :: FilePath -> SearchPath -> IO (LocatedData String) Source #
Traverse the search-path, looking for matching instances of the specified file-name, and either throw an exception, or return a pair composed from the path to the first matching file, together with its contents.
fromFile :: Read a => FilePath -> SearchPath -> IO (LocatedData a) Source #
- Returns the polymorphic data, read from the first matching file on the search-path, along with the path from which it was read.
- Returns an error on failure to parse the contents of the first matching file found on the search-path.
Accessors
getFilePath :: LocatedData a -> FilePath Source #
Accessor.
getData :: LocatedData a -> a Source #
Accessor.