OPAM、OCaml をアップデートする

OCaml コンパイラをインストール

まず opam 自体をアップデートする。パッケージマネージャは MacPorts を使っている。

$ sudo port upgrade opam

1.2 から 2.0 へメジャーバージョンアップということで多少コマンドが変わっているみたい。

opam update でレポジトリの情報を更新する。

$ opam update

opam switch list-available でインストール可能なコンパイラの一覧を表示する。

各種オプション適用版も含めて大量に表示されるのでコンパイラのバージョンだけを見るなら | grep base をつけてもいいかもしれない。

$ opam switch list-available
# or
$ opam switch list-available | grep base

最新のコンパイラ 4.07.1 をインストールしてみる。

$ opam switch create 4.07.1

バージョン 4.07 の変更点などはこちら。

各種パッケージをインストール

お好みで。

$ opam install -y utop
The following actions will be performed:
  ∗ install conf-m4     1          [required by ocamlfind]
  ∗ install ocamlbuild  0.14.0     [required by react]
  ∗ install dune        1.8.2      [required by utop]
  ∗ install ocamlfind   1.8.0      [required by utop]
  ∗ install jbuilder    transition [required by cppo, camomile, lambda-term]
  ∗ install base-bytes  base       [required by zed]
  ∗ install result      1.3        [required by lwt]
  ∗ install cppo        1.6.5      [required by utop]
  ∗ install camomile    1.0.1      [required by utop]
  ∗ install topkg       1.0.0      [required by react]
  ∗ install lwt         4.1.0      [required by utop]                        For the PPX, please install package lwt_ppx
  ∗ install react       1.2.1      [required by utop]
  ∗ install lwt_log     1.1.0      [required by lambda-term]
  ∗ install zed         1.6        [required by lambda-term]
  ∗ install lwt_react   1.1.1      [required by utop]
  ∗ install lambda-term 1.13       [required by utop]
  ∗ install utop        2.3.0
=====17 =====
$ opam install -y ppx_inline_test
The following actions will be performed:
  ∗ install sexplib0                v0.12.0 [required by base]
  ∗ install ocaml-compiler-libs     v0.11.0 [required by ppxlib]
  ∗ install ppx_derivers            1.0     [required by ppxlib]
  ∗ install base                    v0.12.0 [required by ppx_inline_test]
  ∗ install ocaml-migrate-parsetree 1.2.0   [required by ppxlib]
  ∗ install stdio                   v0.12.0 [required by ppxlib]
  ∗ install ppxlib                  0.5.0   [required by ppx_inline_test]
  ∗ install ppx_inline_test         v0.12.0
=====8 =====
$ opam install -y spotlib
The following actions will be performed:
  ∗ install ppx_tools_versioned 5.2.1 [required by ppxx]
  ∗ install seq                 base  [required by re]
  ∗ install ppxx                2.3.2 [required by ppx_test]
  ∗ install re                  1.8.0 [required by ppx_test]
  ∗ install ppx_test            1.6.0 [required by spotlib]
  ∗ install spotlib             4.0.3
=====6 =====
$ opam install -y ocp-indent
The following actions will be performed:
  ∗ install cmdliner   1.0.3 [required by ocp-indent]
  ∗ install ocp-indent 1.7.0
=====2 =====
$ opam install -y merlin
The following actions will be performed:
  ∗ install conf-which  1     [required by biniou]
  ∗ install easy-format 1.3.1 [required by yojson]
  ∗ install biniou      1.2.0 [required by yojson]
  ∗ install yojson      1.7.0 [required by merlin]
  ∗ install merlin      3.2.2
=====5 =====
$ opam install -y js_of_ocaml
The following actions will be performed:
  ∗ install uchar                0.0.2 [required by js_of_ocaml]
  ∗ install js_of_ocaml-compiler 3.3.0 [required by js_of_ocaml]
  ∗ install js_of_ocaml          3.3.0
=====3 =====

OCamlFormat というフォーマッタが開発中らしい。 gofmt みたいにカチッとフォーマットしてくれるのだとしたら嬉しいな。おって試してみるかも。