cabal-info-0.1.0.0: Read information from cabal files

Safe HaskellNone
LanguageHaskell2010

Cabal.Info

Contents

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!

Synopsis

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.

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.

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.

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.