LoginSignup
26
14

More than 5 years have passed since last update.

OCamlの環境構築[Mac OS X]

Last updated at Posted at 2016-09-10

OCamlをOS Xで動かす

OCamlをOS Xで動かそうと思ったら色々詰まったのでメモ

opamを導入する

opamはocamlのパッケージマネージャー.ocamlのバージョン変更もこれでできる
opamはbrewにあるのでそこから導入

$ brew install opam

落ちてきたら初期化が必要だが関連pkgがないとエラーがでる

$ opam init
Checking for available remotes: rsync and local, git.
  - you won't be able to use mercurial repositories unless you install the hg command on your system.
  - you won't be able to use darcs repositories unless you install the darcs command on your system.

なので下記コマンドをいれる

brew install hg
brew install darcs

再度やれば成功する

$ opam init
$ eval `opam config env`

ocamlを使いやすくする

そのままインタプリタを使用すると矢印キーも入力だと受け付けられ使いにくい.
rlwrapを導入し,インタプリタを利用する際はこれから呼ぶ

$ brew install rlwrap
$ echo 'alias ocaml="rlwrap ocaml"' >> ~/.bashrc 

またOCamlのデフォがEUC-JPで使いにくいのでutf-8に変更

~/.ocamlinit
let printer ppf = Format.fprintf ppf "\"%s\"";;
#install_printer printer;;

実行してみる

$ ocaml
        OCaml version 4.03.0

# "hello world!!" ;;
- : string = "hello world!!"

参考

『プログラミングの基礎』社内読書会 #0
UbuntuにOCamlをインストールする

26
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
14