プログラミングの基礎 ((Computer Science Library)) というタイトルからは想像つかないことに、この本を読んでOCamlを勉強している。 本当に最初に関数型言語でプログラムを勉強した人は、どんなプログラマーに育つのだろうか。
OCamlはocaml
コマンドでREPL環境が提供されるのだが、ヒストリーが効かない。
ついキーボードの矢印キーの上を入力して、こうなる
> ocaml OCaml version 4.07.1 # 1 ;; - : int = 1 # ^[[A (* ←ここで上を入れた *)
がっかりだ。
いろいろチェックしてみると、OPAMで入れられるパッケージにREPLを提供するモノがあるらしい。 以下の記事を参考にした。
インストールしてみる。
> opam install utop The following actions will be performed: ∗ install conf-m4 1 [required by ocamlfind] ∗ install dune 1.9.1 [required by utop] ∗ install seq base [required by lwt] ∗ install ocamlbuild 0.14.0 [required by react] ∗ install ocamlfind 1.8.0 [required by utop] ∗ install mmap 1.1.0 [required by lwt] ∗ 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.2.1 [required by utop] ∗ 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.2 [required by utop] ∗ install lambda-term 1.13 [required by utop] ∗ install utop 2.3.0 ===== ∗ 19 ===== Do you want to continue? [Y/n] y <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 [cppo.1.6.5] downloaded from cache at https://opam.ocaml.org/cache [lambda-term.1.13] downloaded from cache at https://opam.ocaml.org/cache [dune.1.9.1] downloaded from cache at https://opam.ocaml.org/cache [lwt.4.2.1] downloaded from cache at https://opam.ocaml.org/cache [lwt_log.1.1.0] downloaded from cache at https://opam.ocaml.org/cache [mmap.1.1.0] downloaded from cache at https://opam.ocaml.org/cache [camomile.1.0.1] downloaded from cache at https://opam.ocaml.org/cache [lwt_react.1.1.2] downloaded from cache at https://opam.ocaml.org/cache [ocamlbuild.0.14.0] downloaded from cache at https://opam.ocaml.org/cache [react.1.2.1] downloaded from cache at https://opam.ocaml.org/cache [result.1.3] downloaded from cache at https://opam.ocaml.org/cache [ocamlfind.1.8.0] downloaded from cache at https://opam.ocaml.org/cache [topkg.1.0.0] downloaded from cache at https://opam.ocaml.org/cache [zed.1.6] downloaded from cache at https://opam.ocaml.org/cache [utop.2.3.0] downloaded from cache at https://opam.ocaml.org/cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫 ∗ installed conf-m4.1 ∗ installed ocamlfind.1.8.0 ∗ installed base-bytes.base ∗ installed seq.base ∗ installed ocamlbuild.0.14.0 ∗ installed dune.1.9.1 ∗ installed jbuilder.transition ∗ installed mmap.1.1.0 ∗ installed result.1.3 ∗ installed cppo.1.6.5 ∗ installed topkg.1.0.0 ∗ installed lwt.4.2.1 ∗ installed react.1.2.1 ∗ installed lwt_log.1.1.0 ∗ installed lwt_react.1.1.2 ∗ installed camomile.1.0.1 ∗ installed zed.1.6 ∗ installed lambda-term.1.13 ∗ installed utop.2.3.0 Done. <><> jbuilder.transition installed successfully <><><><><><><><><><><><><><> 🐫 => Jbuilder has been renamed and the jbuilder package is now a transition package. Use the dune package instead. # Run eval (opam env) to update the current shell environment
便利じゃの。
どういう意味があるのかわからないままeval (opal env)
を実行し、さっそく起動してみる。
な、なんじゃこら。補完もしてくれるのか。凄いな。でも、utop
ってコマンド名が覚えられない気がする(笑)。