在本身寫搭建環境的過程當中,搜了一些博文,有些真的及其不服責任和敷衍,草草幾句話就帶過,可是在google上排名還很高,帶着一種鄙視這些文章的態度,因而寫下這篇文章,但願給後面的人有幫助linux
個人平臺:deepin-15.8,基於debian8,(ubuntu等應該沒太大區別
這裏是一份haskell的學習指南,粗略介紹了安裝,資源等一些東西
根據上面連接的內容,咱們能夠得知:
不推薦使用Haskell-platform直接安裝
也不太推薦使用cabelgit
更推薦使用stack安裝
官網安裝文檔github
For many Un*x operating systems, all you need to do is run://對於unix類系統json
curl -sSL https://get.haskellstack.org/ | sh
or:ubuntu
wget -qO- https://get.haskellstack.org/ | sh
(對於windows系統)On Windows, you can download and install the Windows 64-bit Installer.vim
stack new my-project cd my-project stack setup stack build stack exec my-project-exe
stack new
command will create a new directory containing all the needed files to start a project correctly.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.).stack build
command will build the minimal project.stack exec my-project-exe
will execute the command.stack install <package-name>
.注意,linux系統最好將~/.local/bin加入PATH中
畢竟源在國外,因此咱們首先必需要進行換源,幸虧清華大學開源網站鏡像站有提供,更具體一點能夠看Stackage 鏡像使用說明,這裏記錄下windows
vim ~/.stack/config.yaml # add package-indices: - name: Tsinghua download-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.json lts-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
,下載extension,這裏我推薦這四個插件:Haskell Syntax Highlighting、Haskell ghc-mod 、haskell-linter、Haskelly
,其中第四個插件離不開stack
。
要想使用以上插件,必須安裝如下幾個包:app
# 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
stackoverflow上的解決辦法
我採用了stack install ghc-mod --resolver lts-8.24
去解決curl
github issueide
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.24Basically 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)
stack install --resolver lts-6.6 intero-0.1.15
去解決
而後打開vscode
的配置文件,加上ghc-mod和hlint
的路徑,以下:
"haskell.ghcMod.executablePath": "/home/.local/bin/ghc-mod", "haskell.hlint.executablePath": "/home/.local/bin/hlint"