Haskellでいってみよう

日曜プログラマにも満たないレベルでもHaskellで何かソフトウェアを作りたい!

Haskellコンパイラを入れる

どうやらHaskellコンパイラとしてはGHCがメジャーということらしい。もろもろライブラリも使いたいのでHaskell Platformを入れるのがよいそうで。自宅はMacで、パッケージ管理はHomebrewを使っている。

$ brew install haskell-platform
Warning: haskell-platform-2013.2.0.0 already installed

ああ、前に分けもわからず入れたんだった。ということでHomebrewの更新もやってしまおう。

$ brew update
Cloning into '/usr/local/Library/Taps/homebrew-dupes'...
   :
==> Deleted Formulae
   :
catdoc		    haskell-platform	mpio		    texmacs
   :

あれ?もう一度インストールを試すと

$ brew install haskell-platform
Error: No available formula for haskell-platform
We no longer package haskell-platform. Consider installing ghc
and cabal-install instead:
  brew install ghc cabal-install
    :

どうも"haskell-platform"という名前ではパッケージをインストールできなくなってしまっている。。。
指示通り、ghcとcabal-installを入れてみる。

$ brew install ghc cabal-install
Error: ghc-7.6.3 already installed
To install this version, first `brew unlink ghc'
==> Installing dependencies for cabal-install: gmp, ghc
==> Installing cabal-install dependency: gmp
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gmp-6.0.0a.
######################################################################## 100.0%
==> Pouring gmp-6.0.0a.mavericks.bottle.tar.gz
🍺  /usr/local/Cellar/gmp/6.0.0a: 15 files, 3.2M
==> Installing cabal-install dependency: ghc
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ghc-7.8.3.m
######################################################################## 100.0%
==> Pouring ghc-7.8.3.mavericks.bottle.1.tar.gz
🍺  /usr/local/Cellar/ghc/7.8.3: 5742 files, 724M
==> Installing cabal-install
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/cabal-insta
######################################################################## 100.0%
==> Pouring cabal-install-1.20.0.3_1.mavericks.bottle.1.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/cabal
Target /usr/local/bin/cabal
is a symlink belonging to haskell-platform. You can unlink it:
  brew unlink haskell-platform

To force the link and overwrite all conflicting files:
  brew link --overwrite cabal-install

To list all files that would be deleted:
  brew link --overwrite --dry-run cabal-install

Possible conflicting files are:
/usr/local/bin/cabal -> /usr/local/Cellar/haskell-platform/2013.2.0.0/bin/cabal
==> Summary
🍺  /usr/local/Cellar/cabal-install/1.20.0.3_1: 5 files, 18M
$ ghc -v
Glasgow Haskell Compiler, Version 7.8.3, stage 2 booted by GHC version 7.8.3
    :

何とか入ったらしい。でも、本当にこの手順で良かったのか?