| $decision = $Host.UI.PromptForChoice('Uninstall Haskell' |
| , 'Do you want to uninstall all of the haskell toolchain, including GHC, Cabal, Stack and GHCup itself?' |
| , [System.Management.Automation.Host.ChoiceDescription[]] @('&Uninstall' |
| '&Abort'), 0) |
| |
| if ($decision -eq 1) { |
| Exit 0 |
| } |
| |
| Write-Host 'Removing ghcup toolchain' -ForegroundColor Green |
| ghcup nuke |
| |
| Write-Host 'Unsetting GHCUP_INSTALL_BASE_PREFIX' -ForegroundColor Green |
| [Environment]::SetEnvironmentVariable('GHCUP_INSTALL_BASE_PREFIX', $null, [System.EnvironmentVariableTarget]::User) |
| |
| $ghcupMsys2 = [System.Environment]::GetEnvironmentVariable('GHCUP_MSYS2', 'user') |
| $GhcupBasePrefixEnv = [System.Environment]::GetEnvironmentVariable('GHCUP_INSTALL_BASE_PREFIX', 'user') |
| |
| if ($ghcupMsys2) { |
| $msys2Dir = [IO.Path]::GetFullPath($ghcupMsys2) |
| $baseDir = [IO.Path]::GetFullPath('{0}\ghcup' -f $GhcupBasePrefixEnv) |
| |
| if ($msys2Dir.StartsWith($baseDir)) { |
| Write-Host 'Unsetting GHCUP_MSYS2' -ForegroundColor Green |
| [Environment]::SetEnvironmentVariable('GHCUP_MSYS2', $null, [System.EnvironmentVariableTarget]::User) |
| } else { |
| Write-Host ('GHCUP_MSYS2 env variable is set to a non-standard location {0}. Environment variable not unset. Uninstall manually.' -f $msys2Dir) -ForegroundColor Magenta |
| } |
| } else { |
| Write-Host 'Unsetting GHCUP_MSYS2' -ForegroundColor Green |
| [Environment]::SetEnvironmentVariable('GHCUP_MSYS2', $null, [System.EnvironmentVariableTarget]::User) |
| } |
| |
| Write-Host 'Removing ghcup from PATH env var' -ForegroundColor Green |
| $path = [System.Environment]::GetEnvironmentVariable( |
| 'PATH', |
| 'user' |
| ) |
| $path = ($path.Split(';') | Where-Object { $_ -ne ('{0}\bin' -f $baseDir) }) -join ';' |
| [System.Environment]::SetEnvironmentVariable( |
| 'PATH', |
| $path, |
| 'user' |
| ) |
| |
| Write-Host 'Removing desktop files' -ForegroundColor Green |
| $DesktopDir = [Environment]::GetFolderPath("Desktop") |
| Remove-Item -LiteralPath ('{0}\Install GHC dev dependencies.lnk' -f $DesktopDir) -Force |
| Remove-Item -LiteralPath ('{0}\Mingw haskell shell.lnk' -f $DesktopDir) -Force |
| Remove-Item -LiteralPath ('{0}\Mingw package management docs.url' -f $DesktopDir) -Force |
| |
| Write-Host ('CABAL_DIR env variable is still set to {0} and will be used by cabal regardless of ghcup. You may want to uninstall this manually.' -f [System.Environment]::GetEnvironmentVariable('CABAL_DIR', 'user')) -ForegroundColor Magenta |
| Write-Host 'You may remove this script now.' -ForegroundColor Magenta |
| |
| if ($Host.Name -eq "ConsoleHost") |
| { |
| Write-Host "Press any key to continue..." |
| $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义