HaskellをWindows11にインストールする方法

1. VSCodeでHaskellインストール
2. VSCodeでHaskell GHCi Debug Adapter Phoityneインストール


3. powershellで以下を貼り付け
```
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ }
```


```
Welcome to Haskell!                                                                                                     
This script can download and install the following programs:
  * ghcup - The Haskell toolchain installer
  * ghc   - The Glasgow Haskell Compiler
  * msys2 - A linux-style toolchain environment required for many operations
  * cabal - The Cabal build tool for managing Haskell software
  * stack - (optional) A cross-platform program for developing Haskell projects
  * hls   - (optional) A language server for developers to integrate with their editor/IDE

Please note that ANTIVIRUS may interfere with the installation. If you experience problems, consider
disabling it temporarily.

Where to install to (this should be a short Path, preferably a Drive like 'C:\')?
If you accept this path, binaries will be installed into 'C:\ghcup\bin' and msys2 into 'C:\ghcup\msys64'.
Press enter to accept the default [C:\]:


Setting env variable GHCUP_INSTALL_BASE_PREFIX to 'C:\'
Preparing for GHCup installation...
GHCup already installed at 'C:\\ghcup'...

Install GHCup
GHCup is already installed, what do you want to do?
[R] Reinstall  [C] Continue  [A] Abort  [?] Help (default is "C"): c
Continuing installation...
Specify Cabal directory (this is where haskell packages end up)
Press enter to accept the default [C:\\cabal]:


Install HLS
Do you want to install the haskell-language-server (HLS) for development purposes as well?
[Y] Yes  [N] No  [A] Abort  [?] Help (default is "N"): y

Install stack
Do you want to install stack as well?
[Y] Yes  [N] No  [A] Abort  [?] Help (default is "N"): y
First checking for Msys2...

Install MSys2
Do you want GHCup to install a default MSys2 toolchain (recommended)?
[Y] Yes  [N] No  [?] Help (default is "Y"): y
...Msys2 doesn't exist, installing into C:\\ghcup\msys64
Starting installation in 5 seconds, this may take a while...
Downloading Msys2 archive 20221216...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - 失効の関数は証明書の失効を確認
できませんでした。
Exception: Exec: Error executing command curl.exe with arguments '-o C:\Users\ユーザ名\AppData\Local\Temp\\msys2-base-x86_64-20221216.sfx.exe https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20221216.sfx.exe'
```

うまくいかないので、下記参考にインストール

https://www.haskell.org/ghcup/guide/#troubleshooting

上記はCertificate authority errors (curl)を参照
Certificate authority errors (curl)
If your certificates are outdated or improperly configured, curl may be unable to download ghcup.

There are two known workarounds:

Tell curl to ignore certificate errors (dangerous): curl -k https://raw.githubusercontent.com/haskell/ghcup-hs/master/scripts/bootstrap/bootstrap-haskell | GHCUP_CURL_OPTS="-k" sh
Try to use wget instead: wget -O /dev/stdout https://raw.githubusercontent.com/haskell/ghcup-hs/master/scripts/bootstrap/bootstrap-haskell | BOOTSTRAP_HASKELL_DOWNLOADER=wget sh
On windows, you can disable curl like so:

Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePoin

your Antivirus or Windows Defender interfere with the installation. Disable them temporarily.
→　実行時、ウイルス対策ソフトを無効にしておく

あとは待つだけ

端末を開き
```
C:\Users\ユーザ名>ghci
GHCi, version 9.2.7: https://www.haskell.org/ghc/  :? for help
ghci> 1+1
2
ghci>
```
インストール完了！！

次にVSCodeで以下参考に「プログラムをコンパイル・実行する」を行う

https://zenn.dev/mod_poppo/articles/haskell-setup-2023

これでVSCodeでも使用可能になった

終わり