@@ -47,14 +47,15 @@ import Prelude ()
4747
4848import Distribution.Deprecated.ParseUtils
4949 ( FieldDescr (.. ), ParseResult (.. ), warning , LineNo , lineNo
50- , Field (.. ), liftField , readFieldsFlat )
50+ , Field (.. ), liftField , readFields )
5151import Distribution.Deprecated.ViewAsFieldDescr
5252 ( viewAsFieldDescr )
5353
5454import Distribution.Simple.Command
5555 ( OptionField )
5656
5757import Text.PrettyPrint ( ($+$) )
58+ import qualified Data.ByteString as BS
5859import qualified Data.Map as Map
5960import qualified Text.PrettyPrint as Disp
6061 ( (<>) , Doc , text , colon , vcat , empty , isEmpty , nest )
@@ -243,7 +244,7 @@ parseFieldsAndSections fieldDescrs sectionDescrs fgSectionDescrs =
243244 b <- parseFieldsAndSections fieldDescrs' sectionDescrs' [] sectionEmpty fields
244245 set line param b a
245246 Just (Right (FGSectionDescr _ grammar _getter setter)) -> do
246- let fields1 = mapMaybe convertField fields
247+ let fields1 = map convertField fields
247248 (fields2, sections) = partitionFields fields1
248249 -- TODO: recurse into sections
249250 for_ (concat sections) $ \ (FG. MkSection (F. Name (Position line' _) name') _ _) ->
@@ -262,23 +263,16 @@ parseFieldsAndSections fieldDescrs sectionDescrs fgSectionDescrs =
262263 ++ " ' on line " ++ show line
263264 return a
264265
265- setField accum (block@ IfBlock {}) = do
266- warning $ " Unrecognized stanza on line " ++ show (lineNo block)
267- return accum
268-
269- convertField :: Field -> Maybe (F. Field Position )
270- convertField (F line name str) = Just $
266+ convertField :: Field -> F. Field Position
267+ convertField (F line name str) =
271268 F. Field (F. Name pos (toUTF8BS name)) [ F. FieldLine pos $ toUTF8BS str ]
272269 where
273270 pos = Position line 0
274271-- arguments omitted
275- convertField (Section line name _arg fields) = Just $
276- F. Section (F. Name pos (toUTF8BS name)) [] (mapMaybe convertField fields)
272+ convertField (Section line name _arg fields) =
273+ F. Section (F. Name pos (toUTF8BS name)) [] (map convertField fields)
277274 where
278275 pos = Position line 0
279- -- silently omitted.
280- convertField IfBlock {} = Nothing
281-
282276
283277-- | Much like 'ppFields' but also pretty prints any subsections. Subsection
284278-- are only shown if they are non-empty.
@@ -361,10 +355,10 @@ ppFgSection secName arg grammar x
361355-- It accumulates the result on top of a given initial (typically empty) value.
362356--
363357parseConfig :: [FieldDescr a ] -> [SectionDescr a ] -> [FGSectionDescr FG. ParsecFieldGrammar a ] -> a
364- -> String -> ParseResult a
358+ -> BS. ByteString -> ParseResult a
365359parseConfig fieldDescrs sectionDescrs fgSectionDescrs empty str =
366360 parseFieldsAndSections fieldDescrs sectionDescrs fgSectionDescrs empty
367- =<< readFieldsFlat str
361+ =<< readFields str
368362
369363-- | Render a value in the config file syntax, based on a description of the
370364-- configuration file in terms of its fields and sections.
0 commit comments