Distribution.PackageDescription.Parse

Cabal-2.0.1.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 | Haskell2010

Distribution.PackageDescription.Parse

Contents

- Package descriptions
  - Deprecated names
  - Parsing
  - Private, but needed for pretty-printer
  - 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

- readGenericPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
- parseGenericPackageDescription :: String -> ParseResult GenericPackageDescription
- readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
- parsePackageDescription :: String -> ParseResult GenericPackageDescription
- 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
- data TestSuiteStanza = TestSuiteStanza {
  - testStanzaTestType :: Maybe TestType
  - testStanzaMainIs :: Maybe FilePath
  - testStanzaTestModule :: Maybe ModuleName
  - testStanzaBuildInfo :: BuildInfo
  }
- data BenchmarkStanza = BenchmarkStanza {
  - benchmarkStanzaBenchmarkType :: Maybe BenchmarkType
  - benchmarkStanzaMainIs :: Maybe FilePath
  - benchmarkStanzaBenchmarkModule :: Maybe ModuleName
  - benchmarkStanzaBuildInfo :: BuildInfo
  }
- readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo
- parseHookedBuildInfo :: String -> ParseResult HookedBuildInfo
- pkgDescrFieldDescrs :: [FieldDescr PackageDescription]
- libFieldDescrs :: [FieldDescr Library]
- foreignLibFieldDescrs :: [FieldDescr ForeignLib]
- executableFieldDescrs :: [FieldDescr Executable]
- binfoFieldDescrs :: [FieldDescr BuildInfo]
- sourceRepoFieldDescrs :: [FieldDescr SourceRepo]
- testSuiteFieldDescrs :: [FieldDescr TestSuiteStanza]
- benchmarkFieldDescrs :: [FieldDescr BenchmarkStanza]
- flagFieldDescrs :: [FieldDescr Flag]

# Package descriptions

readGenericPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription Source #

Parse the given package file.

parseGenericPackageDescription :: 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.

## Deprecated names

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

Deprecated: Use readGenericPackageDescription, old name is misleading.

parsePackageDescription :: String -> ParseResult GenericPackageDescription Source #

Deprecated: Use parseGenericPackageDescription, old name is misleading

## Parsing

data ParseResult a Source #

Constructors

ParseFailed PError |
ParseOk [PWarning] a |

Instances

Monad ParseResult # |
Methods (>>=) :: ParseResult a -> (a -> ParseResult b) -> ParseResult b Source # (>>) :: ParseResult a -> ParseResult b -> ParseResult b Source # return :: a -> ParseResult a Source # fail :: String -> ParseResult a Source #
Functor ParseResult # |
Methods fmap :: (a -> b) -> ParseResult a -> ParseResult b Source # (<$) :: a -> ParseResult b -> ParseResult a Source #
MonadFail ParseResult # |
Methods fail :: String -> ParseResult a Source #
Applicative ParseResult # |
Methods pure :: a -> ParseResult a Source # (<*>) :: ParseResult (a -> b) -> ParseResult a -> ParseResult b Source # liftA2 :: (a -> b -> c) -> ParseResult a -> ParseResult b -> ParseResult c Source # (*>) :: ParseResult a -> ParseResult b -> ParseResult b Source # (<*) :: ParseResult a -> ParseResult b -> ParseResult a Source #
Show a => Show (ParseResult a) # |
Methods showsPrec :: Int -> ParseResult a -> ShowS Source # show :: ParseResult a -> String Source # showList :: [ParseResult a] -> ShowS 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 #

## Private, but needed for pretty-printer

data TestSuiteStanza Source #

An intermediate type just used for parsing the test-suite stanza. After validation it is converted into the proper `TestSuite` type.

Constructors

TestSuiteStanza |
Fields testStanzaTestType :: Maybe TestType testStanzaMainIs :: Maybe FilePath testStanzaTestModule :: Maybe ModuleName testStanzaBuildInfo :: BuildInfo

data BenchmarkStanza Source #

An intermediate type just used for parsing the benchmark stanza. After validation it is converted into the proper `Benchmark` type.

Constructors

BenchmarkStanza |
Fields benchmarkStanzaBenchmarkType :: Maybe BenchmarkType benchmarkStanzaMainIs :: Maybe FilePath benchmarkStanzaBenchmarkModule :: Maybe ModuleName benchmarkStanzaBuildInfo :: BuildInfo

## Supplementary build information

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

parseHookedBuildInfo :: String -> ParseResult HookedBuildInfo Source #

pkgDescrFieldDescrs :: [FieldDescr PackageDescription] Source #

libFieldDescrs :: [FieldDescr Library] Source #

foreignLibFieldDescrs :: [FieldDescr ForeignLib] Source #

executableFieldDescrs :: [FieldDescr Executable] Source #

binfoFieldDescrs :: [FieldDescr BuildInfo] Source #

sourceRepoFieldDescrs :: [FieldDescr SourceRepo] Source #

testSuiteFieldDescrs :: [FieldDescr TestSuiteStanza] Source #

benchmarkFieldDescrs :: [FieldDescr BenchmarkStanza] Source #

flagFieldDescrs :: [FieldDescr Flag] Source #