downloadAndInstallGHC :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
           => EnvOverride
           -> SetupInfo
           -> CompilerVersion
           -> VersionCheck
           -> m PackageIdentifier
downloadAndInstallGHC menv si wanted versionCheck = do
    osKey <- getOSKey menv
    pairs <-
        case Map.lookup osKey $ siGHCs si of
            Nothing -> throwM $ UnknownOSKey osKey
            Just pairs -> return pairs
    let mpair =
            listToMaybe $
            sortBy (flip (comparing fst)) $
            filter (\(v, _) -> isWantedCompiler versionCheck wanted (GhcVersion v)) (Map.toList pairs)
    (selectedVersion, downloadInfo) <-
        case mpair of
            Just pair -> return pair
            Nothing -> throwM $ UnknownGHCVersion osKey wanted (Map.keysSet pairs)
    platform <- asks $ configPlatform . getConfig
    let installer =
            case platform of
                Platform _ os | isWindows os -> installGHCWindows
                _ -> installGHCPosix
    downloadAndInstallTool si downloadInfo $(mkPackageName "ghc") selectedVersion installer
downloadAndInstallGHC :: (MonadIO m, MonadMask m, MonadLogger m, MonadReader env m, HasConfig env, HasHttpManager env, MonadBaseControl IO m)
           => EnvOverride
           -> SetupInfo
           -> CompilerVersion
           -> VersionCheck
           -> m PackageIdentifier
downloadAndInstallGHC menv si wanted versionCheck = do
    osKey <- getOSKey menv
    pairs <-
        case Map.lookup osKey $ siGHCs si of
            Nothing -> throwM $ UnknownOSKey osKey
            Just pairs -> return pairs
    let mpair =
            listToMaybe $
            sortBy (flip (comparing fst)) $
            filter (\(v, _) -> isWantedCompiler versionCheck wanted (GhcVersion v)) (Map.toList pairs)
    (selectedVersion, downloadInfo) <-
        case mpair of
            Just pair -> return pair
            Nothing -> throwM $ UnknownGHCVersion osKey wanted (Map.keysSet pairs)
    platform <- asks $ configPlatform . getConfig
    let installer =
            case platform of
                Platform _ os | isWindows os -> installGHCWindows
                _ -> installGHCPosix
    downloadAndInstallTool si downloadInfo $(mkPackageName "ghc") selectedVersion installer
downloadAndInstallGHC menv si wanted versionCheck = do
    osKey <- getOSKey menv
    pairs <-
        case Map.lookup osKey $ siGHCs si of
            Nothing -> throwM $ UnknownOSKey osKey
            Just pairs -> return pairs
    let mpair =
            listToMaybe $
            sortBy (flip (comparing fst)) $
            filter (\(v, _) -> isWantedCompiler versionCheck wanted (GhcVersion v)) (Map.toList pairs)
    (selectedVersion, downloadInfo) <-
        case mpair of
            Just pair -> return pair
            Nothing -> throwM $ UnknownGHCVersion osKey wanted (Map.keysSet pairs)
    platform <- asks $ configPlatform . getConfig
    let installer =
            case platform of
                Platform _ os | isWindows os -> installGHCWindows
                _ -> installGHCPosix
    downloadAndInstallTool si downloadInfo $(mkPackageName "ghc") selectedVersion installer