Cabal-1.22.5.0: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2005
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell98

Distribution.PackageDescription.Parse

Contents

- Package descriptions
  - Parsing
  - Supplementary build information

Description

This defined parsers and partial pretty printers for the `.cabal` format. Some of the complexity in this module is due to the fact that we have to be backwards compatible with old `.cabal` files, so there's code to translate into the newer structure.

Synopsis

- readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
- writePackageDescription :: FilePath -> PackageDescription -> IO ()
- parsePackageDescription :: String -> ParseResult GenericPackageDescription
- showPackageDescription :: PackageDescription -> String
- data ParseResult a
  - = ParseFailed PError
  - | ParseOk [PWarning] a
- data FieldDescr a = FieldDescr {
  - fieldName :: String
  - fieldGet :: a -> Doc
  - fieldSet :: LineNo -> String -> a -> ParseResult a
  }
- type LineNo = Int
- readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo
- parseHookedBuildInfo :: String -> ParseResult HookedBuildInfo
- writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO ()
- showHookedBuildInfo :: HookedBuildInfo -> String
- pkgDescrFieldDescrs :: [FieldDescr PackageDescription]
- libFieldDescrs :: [FieldDescr Library]
- executableFieldDescrs :: [FieldDescr Executable]
- binfoFieldDescrs :: [FieldDescr BuildInfo]
- sourceRepoFieldDescrs :: [FieldDescr SourceRepo]
- testSuiteFieldDescrs :: [FieldDescr TestSuiteStanza]
- flagFieldDescrs :: [FieldDescr Flag]

# Package descriptions

readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription Source

Parse the given package file.

writePackageDescription :: FilePath -> PackageDescription -> IO () Source

parsePackageDescription :: String -> ParseResult GenericPackageDescription Source

Parses the given file into a `GenericPackageDescription`.

In Cabal 1.2 the syntax for package descriptions was changed to a format with sections and possibly indented property descriptions.

showPackageDescription :: PackageDescription -> String Source

## Parsing

data ParseResult a Source

Constructors

ParseFailed PError |
ParseOk [PWarning] a |

Instances

Monad ParseResult Source |
Functor ParseResult Source |
Applicative ParseResult Source |
Show a => Show (ParseResult a) Source |

data FieldDescr a Source

Field descriptor. The parameter `a` parameterizes over where the field's value is stored in.

Constructors

FieldDescr |

Fields

fieldName :: String
fieldGet :: a -> Doc
fieldSet :: LineNo -> String -> a -> ParseResult a

  `fieldSet n str x` Parses the field value from the given input string `str` and stores the result in `x` if the parse was successful. Otherwise, reports an error on line number `n`.

type LineNo = Int Source

## Supplementary build information

readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo Source

parseHookedBuildInfo :: String -> ParseResult HookedBuildInfo Source

writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO () Source

showHookedBuildInfo :: HookedBuildInfo -> String Source

pkgDescrFieldDescrs :: [FieldDescr PackageDescription] Source

libFieldDescrs :: [FieldDescr Library] Source

executableFieldDescrs :: [FieldDescr Executable] Source

binfoFieldDescrs :: [FieldDescr BuildInfo] Source

sourceRepoFieldDescrs :: [FieldDescr SourceRepo] Source

testSuiteFieldDescrs :: [FieldDescr TestSuiteStanza] Source

flagFieldDescrs :: [FieldDescr Flag] Source