refactor nested case statements when installing cabal
This commit is contained in:
parent
59a9a770a5
commit
107fed6e60
31
lib/GHCup.hs
31
lib/GHCup.hs
@ -425,22 +425,23 @@ installCabalBindist dlinfo ver isoFilepath forceInstall = do
|
|||||||
-- check if we already have a regular cabal already installed
|
-- check if we already have a regular cabal already installed
|
||||||
regularCabalInstalled <- checkIfCabalInstalled ver binDir exeExt
|
regularCabalInstalled <- checkIfCabalInstalled ver binDir exeExt
|
||||||
|
|
||||||
case forceInstall of
|
-- check if we already have a regular cabal already installed
|
||||||
True -> case isoFilepath of
|
regularCabalInstalled <- lift $ checkIfToolInstalled Cabal ver
|
||||||
Nothing -> -- force install and a regular install
|
|
||||||
when (regularCabalInstalled)
|
if
|
||||||
(do
|
| forceInstall
|
||||||
lift $ $(logInfo) $ "Removing the currently installed version first!"
|
, regularCabalInstalled
|
||||||
liftE $ rmCabalVer ver)
|
, Nothing <- isoFilepath -> do
|
||||||
|
lift $ $(logInfo) $ "Removing the currently installed version first!"
|
||||||
_ -> pure () -- force install and an isolated install (checks done later while unpacking)
|
liftE $ rmCabalVer ver
|
||||||
|
|
||||||
|
| not forceInstall
|
||||||
|
, regularCabalInstalled
|
||||||
|
, Nothing <- isoFilepath -> do
|
||||||
|
throwE $ AlreadyInstalled Cabal ver
|
||||||
|
|
||||||
|
| otherwise -> pure ()
|
||||||
|
|
||||||
False -> case isoFilepath of
|
|
||||||
Nothing ->
|
|
||||||
when (regularCabalInstalled)
|
|
||||||
(throwE $ AlreadyInstalled Cabal ver)
|
|
||||||
|
|
||||||
_ -> pure ()
|
|
||||||
|
|
||||||
-- download (or use cached version)
|
-- download (or use cached version)
|
||||||
dl <- liftE $ downloadCached dlinfo Nothing
|
dl <- liftE $ downloadCached dlinfo Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user