日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

haskell vscode下的环境搭配(包含各种坑的解决办法)

發布時間:2025/3/17 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 haskell vscode下的环境搭配(包含各种坑的解决办法) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這可能是最傻瓜化的在vscode下的haskell配置介紹文章

為什么要寫這篇文章?

在自己寫搭建環境的過程中,搜了一些博文,有些真的及其不服責任和敷衍,草草幾句話就帶過,但是在google上排名還很高,帶著一種鄙視這些文章的態度,于是寫下這篇文章,希望給后面的人有幫助

安裝haskell

我的平臺:deepin-15.8,基于debian8,(ubuntu等應該沒太大區別

這里是一份haskell的學習指南,粗略介紹了安裝,資源等一些東西
根據上面鏈接的內容,我們可以得知:
不推薦使用Haskell-platform直接安裝
也不太推薦使用cabel

更推薦使用stack安裝
官網安裝文檔

安裝

For many Un*x operating systems, all you need to do is run://對于unix類系統

curl -sSL https://get.haskellstack.org/ | sh

or:

wget -qO- https://get.haskellstack.org/ | sh

(對于windows系統)On Windows, you can download and install the Windows 64-bit Installer.

創建你的project:

stack new my-project cd my-project stack setup stack build stack exec my-project-exe
  • The stack new command will create a new directory containing all the needed files to start a project correctly.
  • The stack setup will download the compiler if necessary in an isolated location (default ~/.stack) that won't interfere with any system-level installations. (For information on installation paths, please use the stack path command.).
  • The stack build command will build the minimal project.
  • stack exec my-project-exe will execute the command.
  • If you just want to install an executable using stack, then all you have to do is stack install <package-name>.
注意,linux系統最好將~/.local/bin加入PATH中

換源

畢竟源在國外,所以我們首先必須要進行換源,幸好清華大學開源網站鏡像站有提供,更具體一點可以看Stackage 鏡像使用說明,這里記錄下

vim ~/.stack/config.yaml # add package-indices: - name: Tsinghuadownload-prefix: https://mirrors.tuna.tsinghua.edu.cn/hackage/package/http: https://mirrors.tuna.tsinghua.edu.cn/hackage/00-index.tar.gz setup-info: "http://mirrors.tuna.tsinghua.edu.cn/stackage/stack-setup.yaml" urls:latest-snapshot: http://mirrors.tuna.tsinghua.edu.cn/stackage/snapshots.jsonlts-build-plans: http://mirrors.tuna.tsinghua.edu.cn/stackage/lts-haskell/nightly-build-plans: http://mirrors.tuna.tsinghua.edu.cn/stackage/stackage-nightly/ # 開始使用stack,這個命令需要稍稍等待 stack setup # 安裝完成之后 stack ghci # 會出現以下輸出 Configuring GHCi with the following packages: GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /private/var/folders/0s/j3c0tlx10z9_x9wzhl14xmgh0000gn/T/ghci11066/ghci-script Prelude>

搭建vscode

打開vscode,下載extension,這里我推薦這四個插件:Haskell Syntax Highlighting、Haskell ghc-mod 、haskell-linter、Haskelly,其中第四個插件離不開stack。
要想使用以上插件,必須安裝以下幾個包:

# for Haskell ghc-mod stack install ghc-mod # for haskell-linter stack install hlint # for Haskelly stack install intero stack install QuickCheck stack install stack-run

安裝時可能出現問題

ghc-mod安裝時如果報錯

stackoverflow上的解決辦法
我采用了
stack install ghc-mod --resolver lts-8.24去解決

stack-run安裝報錯

github issue

I found a workaround.

Create a file: ~/.stack/global-project/stack-cabal-1.24.yaml

flags: {} extra-package-dbs: [] packages: [] extra-deps: [] resolver: lts-8.24

Basically it's using an old stack lts that was from around the time the last update to stack-run was >made.

Then just run this:

stack --stack-yaml ~/.stack/global-project/stack-cabal-1.24.yaml install stack-run

and it should work (did for me, at least)

intero安裝報錯

stack install --resolver lts-6.6 intero-0.1.15去解決

vscode 插件配置

然后打開vscode的配置文件,加上ghc-mod和hlint的路徑,如下:

"haskell.ghcMod.executablePath": "/home/.local/bin/ghc-mod", "haskell.hlint.executablePath": "/home/.local/bin/hlint"

總結

以上是生活随笔為你收集整理的haskell vscode下的环境搭配(包含各种坑的解决办法)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。