From 5a65cddc3bb70fa56e41ac0f5248df105f869e69 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 27 Sep 2024 16:42:51 -0700 Subject: [PATCH] Add type and documentation to `toSavedConfig` This helper function was challenging to understand, so I added an explicit type signature and documentation comments to it. --- cabal-install/src/Distribution/Client/Config.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index 2faf9e1756d..f7b01512ca4 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -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 ) @@ -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