This commit is contained in:
2020-02-24 15:09:38 +01:00
parent b3eac9bf54
commit 30ed7f0226
3 changed files with 32 additions and 16 deletions

View File

@@ -35,7 +35,7 @@ import System.Exit
data Options = Options
{ optVerbose :: Bool
, optCache :: Bool
, optCache :: Bool
, optCommand :: Command
}
@@ -44,13 +44,11 @@ data Command
| InstallCabal InstallCabalOptions
data InstallGHCOptions = InstallGHCOptions
{
ghcVer :: Maybe Version
{ ghcVer :: Maybe Version
}
data InstallCabalOptions = InstallCabalOptions
{
cabalVer :: Maybe Version
{ cabalVer :: Maybe Version
}
@@ -120,17 +118,27 @@ main = do
>>= \opt@Options {..} -> do
let settings = toSettings opt
-- wrapper to run effects with settings
let
runInstTool =
runLogger
. flip runReaderT settings
. runE
@'[FileError, ArchiveError, ProcessError, URLException, PlatformResultError, NoDownload, NoCompatibleArch, DistroNotFound, TagNotFound, AlreadyInstalled]
let runInstTool =
runLogger
. flip runReaderT settings
. runE
@'[ FileError
, ArchiveError
, ProcessError
, URLException
, PlatformResultError
, NoDownload
, NoCompatibleArch
, DistroNotFound
, TagNotFound
, AlreadyInstalled
, NotInstalled
]
case optCommand of
InstallGHC (InstallGHCOptions {..}) ->
void
$ (runInstTool $ do
$ (runInstTool $ do
v <- maybe
( getRecommended availableDownloads GHC
?? TagNotFound Recommended GHC
@@ -142,7 +150,7 @@ main = do
(OwnSpec availableDownloads)
)
>>= \case
VRight _ -> pure ()
VRight _ -> runLogger $ $(logInfo) ([s|GHC installation successful|])
VLeft (V (AlreadyInstalled treq)) ->
runLogger $ $(logWarn)
(T.pack (show treq) <> [s| already installed|])
@@ -161,7 +169,7 @@ main = do
(OwnSpec availableDownloads)
)
>>= \case
VRight _ -> pure ()
VRight _ -> runLogger $ $(logInfo) ([s|Cabal installation successful|])
VLeft (V (AlreadyInstalled treq)) ->
runLogger $ $(logWarn)
(T.pack (show treq) <> [s| already installed|])