140614 土曜 晴れ OS X 10.8.5 に OCaml をインストール

日中は QuickFix/n のサンプルコードを読んだりしていた。
夕方から家族でお出かけ。いつものお寿司屋さん。おいしかった。近くの書店に行く。特に意識していなかった分野の本を手にとって確認できるのは書店ならではの楽しみだ(= Amazon では難しい)。確率の基礎を復習しようと思って薄い参考書を買った。

確率 (モノグラフ (21))
確率 (モノグラフ (21))
posted with amazlet at 14.06.15
村上 哲哉
科学新興新社
売り上げランキング: 188,578

練習問題も付いているので少しずつ勉強しようと思う。
兄に PowerTOP とか cpufreq を見せてもらった。Linuxカーネルやドライバなど開発が進めばそれをすぐに(やる気と知識さえあれば)個人の環境にも適用できるのですごいなと思う。

寝る前に OCaml をノート PC にインストールしてみた。OPAM というパッケージマネージャを入れるのがよいらしいので、まずは MacPorts で OPAM をインストールする。

$ sudo port install opam
$ opam init --comp 4.01.0

opam init は --comp オプションのあとにバージョン番号を指定する必要がある。mizchi さんのエントリを参考に 4.01.0 にしておいた。

しばらく処理に時間がかかり、最後に入力を求められる。

In normal operation, OPAM only alters files within ~/.opam.

During this initialisation, you can allow OPAM to add information to two
other files for best results. You can also make these additions manually
if you wish.

If you agree, OPAM will modify:

  - ~/.bash_profile (or a file you specify) to set the right environment
    variables and to load the auto-completion scripts for your shell (bash)
    on startup. Specifically, it checks for and appends the following line:

    . ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

  - ~/.ocamlinit to ensure that non-system installations of `ocamlfind`
    (i.e. those installed by OPAM) will work correctly when running the
    OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list
    of include directories.

If you choose to not configure your system now, you can either configure
OPAM manually (instructions will be displayed) or launch the automatic setup
later by running:

   `opam config setup -a`.


Do you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bash_profile)
    [N/y/f] y

設定ファイル .bash_profile を編集するか?ということなのでお願いしてみる。

最後、以下のコマンドを実行するように言われるのでその通りにする。

$ eval `opam config env`

ocaml コマンドは $HOME に .opam というディレクトリができてその中にはいったようだ。

$ which ocaml
/Users/ryosuke/.opam/4.01.0/bin/ocaml

ocaml と入力すると対話環境が立ち上がる。抜けるには #quit と入力する。

# #quit