Oh yeah
This commit is contained in:
36
app/Main.hs
36
app/Main.hs
@@ -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|])
|
||||
|
||||
Reference in New Issue
Block a user