8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Haskell開発環境をWindows 10に構築したメモ(Windows Subsystem for Linux + stack)

Last updated at Posted at 2018-09-23

大まかな手順

※実際に試した手順とは異なる(後述)

  1. Windows Subsystem for Linuxをインストール
  2. bashからstackをインストール
  3. stack ghci

Windows Subsystem for Linuxをインストール

Windows Subsystem for Linuxをインストールしてみよう!」の手順通り。
以降は全てbash上の操作(インストールしたUbuntuを起動)。

/etc/apt/sources.listの編集はやめておく

/etc/apt/sources.listを編集するとハマった。
haskell-platformがインストールできなかった。
最低限sedする前にバックアップをとっておく。

$ sudo apt-get install haskell-platform
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package haskell-platform

デフォルトの/etc/apt/sources.listでは無事インストールできたが、最終的にapt-get purgeした(後述)。

stackのインストール

結論から書くとこれ

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

(おまけ)haskell-platformをインストールしたけど、ghciもstackも入ってない

※(追記)ghciは実際には入っていて、単なるtypoで見つからなかった可能性大

sudo apt-get install haskell-platform

haskell-platformをインストールした。
ghcrunghcも動いた。
しかし..

$ stack ghci
Command 'stack' not found, but can be installed with:
sudo apt install haskell-stack

$ gchi
Command 'gchi' not found, did you mean:
..

※(追記)typo [正]ghci [誤]gchi
..さようなら、haskell-platform

sudo apt-get purge haskell-platform

apt-getでインストールしたstackが動かない

$ sudo apt-get install haskell-stack
..
$ stack ghci
Writing implicit global project config file to: /home/hugin/.stack/global-project/stack.yaml
Note: You can change the snapshot via the resolver field there.
Using latest snapshot resolver: lts-12.10
Downloaded lts-12.10 build plan.
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""

AesonException Invalid flag name: \"bytestring--lt-0_10_4\""」に解決方法が。

With 1.7.1, you should no longer get the AesonException
I have uninstalled the system's haskell-stack and the one installed locally. I've run curl -sSL https://get.haskellstack.org/ | sh and now all is fine. Thank you.

haskell-stackをアンインストールせずに実行して失敗したので、下のコマンドを実行して無理やりインストールした(非推奨)。

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

stack ghci

stack ghci

ghciがインストールされてない場合はインストールされる。
インストール完了後、ghciが起動する。

Prelude> :q

で終了する。

ghciの起動も動作もサクサク

以下のような記事があって心配したが、実際はサクサク動いている。
SSDの恩恵か、単に最新の環境では解消しているのか。

$ time stack ghc -- -e 'print "Java + You"'
"Java + You"

real    0m0.315s
user    0m0.219s
sys     0m0.172s

ghci(Haskellの対話実行環境)やビルドが異常に遅いのです。下記の簡単なワンライナー実行するだけで6秒もかかります。
Haskell入門しようとして環境構築で失敗。

ghcやghciやrunghcの起動にいちいち2分ぐらいかかる。
Windows Subsystem for Linuxをインストールしてみよう!

実際の手順

本記事の手順は、実際に実施した手順と異なるため失敗するかもしれない。
このように迷走したことにより、たまたまうまく行っているコマンドがあるかもしれない。

  1. Windows Subsystem for Linuxをインストール
  2. sudo apt-get install haskell-platform
  3. sudo apt-get install haskell-stack
  4. curl -sSL https://get.haskellstack.org/ | sh -s - -f
  5. sudo apt-get purge haskell-platform
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?