Field descriptor. The parameter a parameterizes over where the field's
value is stored in.
Modulecabal-install-3.12.1.0Haskell2010
Distribution.Client.ParseUtils
Parsing utilities.
- 3 types
- 14 values
- Packagecabal-install-3.12.1.0
- Exports17
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceParseUtils.hs
Fields and field utilities
7 declarationsGiven a collection of field descriptions, keep only a given list of them, identified by name.
Apply a name mangling function to the field names of all the field descriptions. The typical use case is to apply some prefix.
Reuse a command line OptionField as a config file FieldDescr.
Reuse a bunch of command line OptionFields as config file FieldDescrs.
Sections and utilities
2 declarationsThe description of a section in a config file. It can contain both fields and optionally further subsections. See also FieldDescr.
Constructors
forall b. SectionDescrsectionName :: StringsectionFields :: [FieldDescr b]sectionSubsections :: [SectionDescr b]sectionGet :: a -> [(String, b)]sectionSet :: LineNo -> String -> b -> a -> ParseResult asectionEmpty :: b
To help construction of config file descriptions in a modular way it is useful to define fields and sections on local types and then hoist them into the parent types when combining them in bigger descriptions.
This is essentially a lens operation for SectionDescr to help embedding one inside another.
FieldGrammar sections
1 declarationFieldGrammar section description
Constructors
forall s. FGSectionDescrfgSectionName :: StringfgSectionGrammar :: g s sfgSectionGet :: a -> [(String, s)]fgSectionSet :: LineNo -> String -> s -> a -> ParseResult a
Parsing and printing flat config
3 declarationsParse a bunch of semi-parsed Fields according to a set of field
descriptions. It accumulates the result on top of a given initial value.
This only covers the case of flat configuration without subsections. See also parseFieldsAndSections.
This is a customised version of the functions from Distribution.Deprecated.ParseUtils that also optionally print default values for empty fields as comments.
Pretty print a section.
Since ppFields does not cover subsections you can use this to add them. Or alternatively use a SectionDescr and use ppFieldsAndSections.
Parsing and printing config with sections and subsections
2 declarationsparseFieldsAndSections :: [FieldDescr a]field
-> [SectionDescr a]legacy sections
-> [FGSectionDescr ParsecFieldGrammar a]FieldGrammar sections
-> a-> [Field]-> ParseResult a
Much like parseFields but it also allows subsections. The permitted subsections are given by a list of SectionDescrs.
Top level of config files
Parse a string in the config file syntax into a value, based on a description of the configuration file in terms of its fields and sections.
It accumulates the result on top of a given initial (typically empty) value.
Render a value in the config file syntax, based on a description of the configuration file in terms of its fields and sections.