Commit 5b5f729a authored by barmston's avatar barmston
Browse files

Frozen dependencies are printed on their own lines

A new pretty-print has been introduced `D.ParseUtils.commaNewLineListField`.
It is similar to `D.ParseUtils.commaListField` but has each item on its own
line.

The constraints section of the package environment is pretty printed with
`commaNewLineListField`.
parent 774d76d8
......@@ -33,7 +33,7 @@ module Distribution.ParseUtils (
parseSepList, parseCommaList, parseOptCommaList,
showFilePath, showToken, showTestedWith, showFreeText, parseFreeText,
field, simpleField, listField, spaceListField, commaListField,
optsField, liftField, boolField, parseQuoted,
commaNewLineListField, optsField, liftField, boolField, parseQuoted,
UnrecFieldParser, warnUnrec, ignoreUnrec,
) where
......@@ -188,14 +188,22 @@ simpleField :: String -> (a -> Doc) -> ReadP a a
simpleField name showF readF get set
= liftField get set $ field name showF readF
commaListField :: String -> (a -> Doc) -> ReadP [a] a
commaListField' :: ([Doc] -> Doc) -> String -> (a -> Doc) -> ReadP [a] a
-> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaListField name showF readF get set =
commaListField' separator name showF readF get set =
liftField get set' $
field name (fsep . punctuate comma . map showF) (parseCommaList readF)
field name (separator . punctuate comma . map showF) (parseCommaList readF)
where
set' xs b = set (get b ++ xs) b
commaListField :: String -> (a -> Doc) -> ReadP [a] a
-> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaListField = commaListField' fsep
commaNewLineListField :: String -> (a -> Doc) -> ReadP [a] a
-> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaNewLineListField = commaListField' sep
spaceListField :: String -> (a -> Doc) -> ReadP [a] a
-> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
spaceListField name showF readF get set =
......
......@@ -46,7 +46,7 @@ import Distribution.Simple.Setup ( Flag(..), ConfigFlags(..)
, fromFlagOrDefault, toFlag, flagToMaybe )
import Distribution.Simple.Utils ( die, info, notice, warn, lowercase )
import Distribution.ParseUtils ( FieldDescr(..), ParseResult(..)
, commaListField
, commaListField, commaNewLineListField
, liftField, lineNo, locatedErrorMsg
, parseFilePathQ, readFields
, showPWarning, simpleField
......@@ -390,7 +390,7 @@ pkgEnvFieldDescrs = [
pkgEnvInherit (\v pkgEnv -> pkgEnv { pkgEnvInherit = v })
-- FIXME: Should we make these fields part of ~/.cabal/config ?
, commaListField "constraints"
, commaNewLineListField "constraints"
Text.disp Text.parse
(configExConstraints . savedConfigureExFlags . pkgEnvSavedConfig)
(\v pkgEnv -> updateConfigureExFlags pkgEnv
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment