Cabal-2.2.0.0: A framework for packaging Haskell software

Safe HaskellNone
LanguageHaskell2010

Distribution.FieldGrammar.Parsec

Contents

Description

This module provides a FieldGrammarParser, one way to parse .cabal -like files.

Fields can be specified multiple times in the .cabal files. The order of such entries is important, but the mutual ordering of different fields is not.Also conditional sections are considered after non-conditional data. The example of this silent-commutation quirk is the fact that

buildable: True
if os(linux)
  buildable: False

and

if os(linux)
  buildable: False
buildable: True

behave the same! This is the limitation of GeneralPackageDescription structure.

So we transform the list of fields [Field ann] into a map of grouped ordinary fields and a list of lists of sections: Fields ann = Map FieldName [NamelessField ann] and [[Section ann]].

We need list of list of sections, because we need to distinguish situations where there are fields in between. For example

if flag(bytestring-lt-0_10_4)
  build-depends: bytestring < 0.10.4

default-language: Haskell2020

else
  build-depends: bytestring >= 0.10.4

is obviously invalid specification.

We can parse Fields like we parse aeson objects, yet we use slighly higher-level API, so we can process unspecified fields, to report unknown fields and save custom x-fields.

Synopsis

Documentation

data ParsecFieldGrammar s a Source #

Instances
FieldGrammar ParsecFieldGrammar Source # 
Instance details
Functor (ParsecFieldGrammar s) Source # 
Instance details
Applicative (ParsecFieldGrammar s) Source # 
Instance details

Auxiliary

data NamelessField ann Source #

Single field, without name, but with its annotation.

Constructors

MkNamelessField !ann [FieldLine ann] 
Instances
Functor NamelessField Source # 
Instance details

Methods

fmap :: (a -> b) -> NamelessField a -> NamelessField b Source #

(<$) :: a -> NamelessField b -> NamelessField a Source #

Eq ann => Eq (NamelessField ann) Source # 
Instance details

Methods

(==) :: NamelessField ann -> NamelessField ann -> Bool #

(/=) :: NamelessField ann -> NamelessField ann -> Bool #

Show ann => Show (NamelessField ann) Source # 
Instance details

data Section ann Source #

The Section constructor of Field.

Constructors

MkSection !(Name ann) [SectionArg ann] [Field ann] 
Instances
Functor Section Source # 
Instance details

Methods

fmap :: (a -> b) -> Section a -> Section b Source #

(<$) :: a -> Section b -> Section a Source #

Eq ann => Eq (Section ann) Source # 
Instance details

Methods

(==) :: Section ann -> Section ann -> Bool #

(/=) :: Section ann -> Section ann -> Bool #

Show ann => Show (Section ann) Source # 
Instance details

Methods

showsPrec :: Int -> Section ann -> ShowS Source #

show :: Section ann -> String Source #

showList :: [Section ann] -> ShowS Source #