てきとーなブログ

てきとーに書き綴ります。なので、正しいかは責任を負えません。

haskell事始め

とある事情でhaskellを試すこととなったのでその際の記録を残しておく。環境はubuntu15.04。 今後使うことはないとは思うけど。。。

インストール

sudo apt-get install haskell-platform

emacshaskell-mode

はじめにレポジトリに追加。

M-x customize-option RET package-archives

M-xはwindowsでいうAlt-x押しのこと。RET(RETURN)はenterのこと。

で、archive nameにmelpa-stable、URL or directory nameにhttp://stable.melpa.org/packages/ そしてApllyをクリック。

次にパッケージリストを取り出す。

M-x package-reresh-contents

そして、インストール。

M-x package-refresh-contents

インデントを付けたければemacsの設定ファイル(~/.emacs or ~/.emacs.d/init.el)に下記を追加。

(add-hook 'haskell-mode-hook 'haskell-indentation-mode)

とりあえずhello world

hello.hsを適当につくって

main =
  print "hello world!"

コンパイル

ghc hello.hs       
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking hello ...
./hello 
"hello world!"