在本身写搭建环境的过程当中,搜了一些博文,有些真的及其不服责任和敷衍,草草几句话就带过,可是在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"