Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cabal.Info
Description
Get information from cabal files.
Motivating example, test discovery based on a library's exposed modules:
import Test.Doctest (doctest) import Cabal.Info (getLibraryModules) main :: IO () main = getLibraryModules >>= doctest . either (const []) id
Simple!
- findCabalFile :: IO (Maybe FilePath)
- findPackageDescription :: IO (Either CabalError (PackageDescription, FilePath))
- findPackageDescription' :: FlagAssignment -> Maybe OS -> Maybe Arch -> IO (Either CabalError (PackageDescription, FilePath))
- findGenericPackageDescription :: IO (Either CabalError (GenericPackageDescription, FilePath))
- openPackageDescription :: FilePath -> IO (Either CabalError PackageDescription)
- openPackageDescription' :: FlagAssignment -> Maybe OS -> Maybe Arch -> FilePath -> IO (Either CabalError PackageDescription)
- openGenericPackageDescription :: FilePath -> IO (Either CabalError GenericPackageDescription)
- data CabalError
- prettyPrintErr :: CabalError -> String
- evaluateConditions :: FlagAssignment -> Maybe OS -> Maybe Arch -> Maybe FilePath -> GenericPackageDescription -> Either CabalError PackageDescription
- getLibrary :: IO (Either CabalError Library)
- getLibraryModules :: IO (Either CabalError [FilePath])
- moduleFilePath :: BuildInfo -> ModuleName -> FilePath
Reading .cabal files
findCabalFile :: IO (Maybe FilePath) Source #
Find the .cabal file.
If there are .cabal files in the current directory, the first is read. Otherwise, the parent directory is checked. This continues until the filesystem root is reached without finding a .cabal file.
findPackageDescription :: IO (Either CabalError (PackageDescription, FilePath)) Source #
Find and read the .cabal file, applying the default flags.
findPackageDescription' :: FlagAssignment -> Maybe OS -> Maybe Arch -> IO (Either CabalError (PackageDescription, FilePath)) Source #
Find and read the .cabal file, applying the given flags, operating system, and architecture.
findGenericPackageDescription :: IO (Either CabalError (GenericPackageDescription, FilePath)) Source #
Find and read the .cabal file.
openPackageDescription :: FilePath -> IO (Either CabalError PackageDescription) Source #
Open and parse a .cabal file, applying the default flags.
openPackageDescription' :: FlagAssignment -> Maybe OS -> Maybe Arch -> FilePath -> IO (Either CabalError PackageDescription) Source #
Open and parse a .cabal file, and apply the given flags, operating system, and architecture.
openGenericPackageDescription :: FilePath -> IO (Either CabalError GenericPackageDescription) Source #
Open and parse a .cabal file.
Errors
data CabalError Source #
Automatically finding and dealing with a .cabal file failed for some reason.
Constructors
NoCabalFile | A .cabal file could not be found in the current directory or any of its parents. |
ParseError FilePath PError | A file with the extension .cabal was found, but could not be parsed. |
NoFlagAssignment (Maybe FilePath) | A consistent flag assignment could not be found. |
NoLibrary FilePath | There is no library section. |
Instances
prettyPrintErr :: CabalError -> String Source #
Pretty-print an error.
Conditionals
evaluateConditions :: FlagAssignment -> Maybe OS -> Maybe Arch -> Maybe FilePath -> GenericPackageDescription -> Either CabalError PackageDescription Source #
Apply the given flags, operating system, and architecture.
Libraries
getLibrary :: IO (Either CabalError Library) Source #
Search for the .cabal file and return its library section.
getLibraryModules :: IO (Either CabalError [FilePath]) Source #
Search for the .cabal file and return its exposed library modules, as absolute paths.
Modules
moduleFilePath :: BuildInfo -> ModuleName -> FilePath Source #
Turn a module name + some build info to a file path taking the hs-source-dirs field into account.
This path will be relative to the .cabal file.