Only run unsafeInterleaveIO when necessary

This commit is contained in:
Julian Ospald 2021-07-15 20:30:14 +02:00
parent bf74d1e828
commit 7e14fd4a08
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F
1 changed files with 6 additions and 2 deletions

View File

@ -1244,8 +1244,12 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
-- Getting download and platform info -- -- Getting download and platform info --
---------------------------------------- ----------------------------------------
-- for some commands we want lazy loading
let wrapIO = case optCommand of
Whereis _ _ -> unsafeInterleaveIO
_ -> id
pfreq <- unsafeInterleaveIO $ ( pfreq <- wrapIO $ (
runLogger . runE @'[NoCompatiblePlatform, NoCompatibleArch, DistroNotFound] . liftE $ platformRequest runLogger . runE @'[NoCompatiblePlatform, NoCompatibleArch, DistroNotFound] . liftE $ platformRequest
) >>= \case ) >>= \case
VRight r -> pure r VRight r -> pure r
@ -1254,7 +1258,7 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
($(logError) $ T.pack $ prettyShow e) ($(logError) $ T.pack $ prettyShow e)
exitWith (ExitFailure 2) exitWith (ExitFailure 2)
ghcupInfo <- unsafeInterleaveIO $ ghcupInfo <- wrapIO $
( runLogger ( runLogger
. runE @'[JSONError , DownloadFailed, FileDoesNotExistError] . runE @'[JSONError , DownloadFailed, FileDoesNotExistError]
$ liftE $ liftE