Open3
Haskellでの開発環境構築 on ubuntu
![jnuank](https://res.cloudinary.com/zenn/image/fetch/s--XmS8kM_t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/f27664d393.jpeg)
最近はghcupという一通り必要なものが入れられるらしい
$ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
Welcome to Haskell!
This script can download and install the following binaries:
* ghcup - The Haskell toolchain installer
* ghc - The Glasgow Haskell Compiler
* cabal - The Cabal build tool for managing Haskell software
* stack - A cross-platform program for developing Haskell projects (similar to cabal)
* hls - (optional) A language server for developers to integrate with their editor/IDE
ghcup installs only into the following directory,
which can be removed anytime:
/home/user/.ghcup
Press ENTER to proceed or ctrl-c to abort.
Note that this script can be re-run at any given time.
いくつか質問があるのでそれに答えていくだけ。
-------------------------------------------------------------------------------
Detected zsh shell on your system...
Do you want ghcup to automatically add the required PATH variable to "/home/user/.zshrc"?
[P] Yes, prepend [A] Yes, append [N] No [?] Help (default is "P").
使用しているshellの環境に合わせてパスを追記してくれる。
先頭か最後に追記かはお好みで。
-------------------------------------------------------------------------------
Do you want to install haskell-language-server (HLS)?
HLS is a language-server that provides IDE-like functionality
and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ...
Also see https://haskell-language-server.readthedocs.io/en/stable/
[Y] Yes [N] No [?] Help (default is "N").
HLSをinstallするかどうか。
-------------------------------------------------------------------------------
Do you want to enable better integration of stack with GHCup?
This means that stack won't install its own GHC versions, but uses GHCup's.
For more information see:
https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental
If you want to keep stacks vanilla behavior, answer 'No'.
yesにすると、stackがghcupで管理しているGHCを使うようになるらしい。
stack buildしたときに必要なGHC versionをインストールするらしいけど、それを勝手にやらないということっぽい。
System requirements
Please ensure the following distro packages are installed before continuing (you can exit ghcup and return at any time): build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5
Press ENTER to proceed or ctrl-c to abort.
Installation may take a while.
実行する前にこれらのパッケージ入っているかの確認しておいてね、というメッセージ。
apt list で確認。
apt list --installed
OKだったらEnter。
All done!
To start a simple repl, run:
ghci
To start a new haskell project in the current directory, run:
cabal init --interactive
To install other GHC versions and tools, run:
ghcup tui
If you are new to Haskell, check out https://www.haskell.org/ghcup/steps/
終了。
ghciが実行できるか確認して、repl起動したのでOKそう
![jnuank](https://res.cloudinary.com/zenn/image/fetch/s--XmS8kM_t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/f27664d393.jpeg)
vscodeでHLSを使うように設定する。
参考
-
VSCodeで拡張機能をインストールする
https://marketplace.visualstudio.com/items?itemName=haskell.haskell -
settingから
haskel
を検索して、ManageHLSにGHCup
を選択する
-
llvmをinstall必要があるっぽいので、入れる
apt install llvm
![jnuank](https://res.cloudinary.com/zenn/image/fetch/s--XmS8kM_t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/f27664d393.jpeg)
stack test
stack new ${project-name} hspec
stack test