[commit: packages/Cabal] ghc-head: Refactoring. (a302862)
git at git.haskell.org
git at git.haskell.org
Mon Aug 26 23:27:08 CEST 2013
Repository : ssh://git@git.haskell.org/Cabal
On branch : ghc-head
Link : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=a3028624a452e003a48199ec8e898b780c0a257b
>---------------------------------------------------------------
commit a3028624a452e003a48199ec8e898b780c0a257b
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date: Mon Jun 10 00:37:23 2013 +0200
Refactoring.
Introduce two helper functions to break a giant case statement.
>---------------------------------------------------------------
a3028624a452e003a48199ec8e898b780c0a257b
cabal-install/Main.hs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/cabal-install/Main.hs b/cabal-install/Main.hs
index d40c78a..18be4d9 100644
--- a/cabal-install/Main.hs
+++ b/cabal-install/Main.hs
@@ -342,14 +342,18 @@ reconfigure :: Verbosity -- ^ Verbosity setting
reconfigure verbosity distPref addConfigFlags extraArgs globalFlags
skipAddSourceDepsCheck numJobsFlag checkFlags = do
eLbi <- tryGetPersistBuildConfig distPref
-
case eLbi of
+ Left (err, errCode) -> onNoBuildConfig err errCode
+ Right lbi -> onBuildConfig lbi
+
+ where
-- We couldn't load the saved package config file.
--
-- If we're in a sandbox: add-source deps don't have to be reinstalled
-- (since we don't know the compiler & platform).
- Left (err, errCode) -> do
+ onNoBuildConfig :: String -> ConfigStateFileErrorType -> IO UseSandbox
+ onNoBuildConfig err errCode = do
let msg = case errCode of
ConfigStateFileMissing -> "Package has never been configured."
ConfigStateFileCantParse -> "Saved package config file seems "
@@ -370,7 +374,8 @@ reconfigure verbosity distPref addConfigFlags extraArgs globalFlags
--
-- If we're in a sandbox: reinstall the modified add-source deps and
-- force reconfigure if we did.
- Right lbi -> do
+ onBuildConfig :: LBI.LocalBuildInfo -> IO UseSandbox
+ onBuildConfig lbi = do
let configFlags = LBI.configFlags lbi
flags = mconcat [configFlags, addConfigFlags, distVerbFlags]
savedDistPref = fromFlagOrDefault
@@ -421,7 +426,7 @@ reconfigure verbosity distPref addConfigFlags extraArgs globalFlags
configureAction (flags, defaultConfigExFlags)
extraArgs globalFlags
return useSandbox
- where
+
defaultFlags = mappend addConfigFlags distVerbFlags
distVerbFlags = mempty
{ configVerbosity = toFlag verbosity
More information about the ghc-commits
mailing list