HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Fields and field utilities

7 declarations
datadata FieldDescr a
#

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

Constructors

  • FieldDescr
    • 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.

Sections and utilities

2 declarations
valueliftSection :: (b -> a) -> (a -> b -> b) -> SectionDescr a -> SectionDescr 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 declaration

Parsing and printing flat config

3 declarations
valueparseFields :: [FieldDescr a] -> a -> [Field] -> ParseResult a
#

Parse 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.

valueppFields :: [FieldDescr a] -> Maybe a -> a -> Doc
#

This is a customised version of the functions from Distribution.Deprecated.ParseUtils that also optionally print default values for empty fields as comments.

Parsing and printing config with sections and subsections

2 declarations

Top level of config files