Skip to content

Commit

Permalink
Add type and documentation to toSavedConfig
Browse files Browse the repository at this point in the history
This helper function was challenging to understand, so I added
an explicit type signature and documentation comments to it.
  • Loading branch information
9999years authored and Mikolaj committed Oct 7, 2024
1 parent 67539e7 commit 5a65cdd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import qualified Distribution.Deprecated.ParseUtils as ParseUtils
import Distribution.Parsec (ParsecParser, parsecFilePath, parsecOptCommaList, parsecToken)
import Distribution.Simple.Command
( CommandUI (commandOptions)
, OptionField
, ShowOrParseArgs (..)
, commandDefaultFlags
)
Expand Down Expand Up @@ -1314,6 +1315,19 @@ configFieldDescriptions src =
ParseArgs
]
where
toSavedConfig
:: (FieldDescr a -> FieldDescr SavedConfig)
-- Lifting function.
-> [OptionField a]
-- Option fields.
-> [String]
-- Fields to exclude, by name.
-> [FieldDescr a]
-- Field replacements.
--
-- If an option is found with the same name as one of these replacement
-- fields, the replacement field is used instead of the option.
-> [FieldDescr SavedConfig]
toSavedConfig lift options exclusions replacements =
[ lift (fromMaybe field replacement)
| opt <- options
Expand Down

0 comments on commit 5a65cdd

Please sign in to comment.