@@ -118,24 +118,30 @@ renderPackageWith settings headerFieldsAlignment existingFieldOrder sectionsFiel
118118 , (" version" , Just packageVersion)
119119 , (" synopsis" , packageSynopsis)
120120 , (" description" , (formatDescription packageCabalVersion headerFieldsAlignment <$> packageDescription))
121- , ( " category" , packageCategory)
121+ , formatList " category" packageCategory
122122 , (" stability" , packageStability)
123123 , (" homepage" , packageHomepage)
124124 , (" bug-reports" , packageBugReports)
125- , ( " author" , formatList packageAuthor)
126- , ( " maintainer" , formatList packageMaintainer)
127- , ( " copyright" , formatList packageCopyright)
125+ , formatList " author" packageAuthor
126+ , formatList " maintainer" packageMaintainer
127+ , formatList " copyright" packageCopyright
128128 , (" license" , packageLicense)
129129 , case packageLicenseFile of
130130 [file] -> (" license-file" , Just file)
131- files -> ( " license-files" , formatList files)
131+ files -> formatList " license-files" files
132132 , (" build-type" , Just (show packageBuildType))
133133 ]
134134
135- formatList :: [String ] -> Maybe String
136- formatList xs = guard ( not $ null xs) >> ( Just $ intercalate separator xs)
135+ formatList :: String -> [String ] -> ( String , Maybe String )
136+ formatList field = (,) field . formatValues
137137 where
138- separator = let Alignment n = headerFieldsAlignment in " ,\n " ++ replicate n ' '
138+ formatValues :: [String ] -> Maybe String
139+ formatValues values = guard (not $ null values) >> (Just $ intercalate separator values)
140+ where
141+ separator :: String
142+ separator = " ,\n " ++ replicate n ' '
143+ where
144+ Alignment n = max headerFieldsAlignment (Alignment $ length field + 2 )
139145
140146sortStanzaFields :: [(String , [String ])] -> [Element ] -> [Element ]
141147sortStanzaFields sectionsFieldOrder = go
0 commit comments