kakinouchi / spring-2019-asai

プログラミングの基礎(浅井)の写経レポジトリ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spring

『プログラミングの基礎(浅井健一)』(サイエンス社)の写経レポジトリ
1.関数型プログラミングに慣れたい・2.テストをちゃんと書けるようにしたいという動機で読み始めた。アルゴリズムの練習にもなりそう。

環境構築メモ(2019/02/23)

  1. brew install opam
  2. opam init
    • opam install merlin(コード補完ツール?)
    • opam install dune(ビルドツール)
    • opam install ocamlformat(フォーマッタ)
    • opam install ocp-indent(format on save for OCaml in VSCode cf:reasonml-editor/vscode-reasonml#247)
  • ビルドツールは最近は dune が良さそう。(デファクトスタンダードになりそう?)
  • VSCode のプラグイン:OCaml and Reason IDEで Connection got disposed というエラーが出てたが、ocp-indent を入れたら直った(reasonml-editor/vscode-reasonml#247)

dune メモ

  • 開発者(?)による解説動画が良かった
  • 読み方は dʒúːn のようだ(dúːn かと思った)
  • cross platforms
  • 公式のquick startにあるように、1.duneファイルを作って2行ほど書き、2.dune buildコマンドを叩けば(cross platformな)実行ファイルが出来上がる。3.実行ファイルはdune exec ./hello_world.exe で実行できる。

例:

$ ls
README.md	dune		hello_world.ml

$ cat dune
(executable
 (name hello_world))

$ cat hello_world.ml
print_endline "hello, world!"

$ dune build hello_world.exe
Info: creating file dune-project with this contents:
| (lang dune 1.7)

$ ls
README.md	_build		dune		dune-project	hello_world.ml

$ dune exec ./hello_world.exe
hello, world!

About

プログラミングの基礎(浅井)の写経レポジトリ


Languages

Language:OCaml 100.0%