Haskell入門 1.2 〜 1.3
- 作者: 本間雅洋,類地孝介,逢坂時響
- 出版社/メーカー: 技術評論社
- 発売日: 2017/09/27
- メディア: 大型本
- この商品を含むブログを見る
コンパイラとしてGHC、ビルドツールとしてStackを使う。
1.2 実行環境の構築
Stackのインストール
curl -sSL https://get.haskellstack.org/ | sh
WARNINGが出た。
WARNING: '/Users/yoshikiito/.local/bin' is not on your PATH. For best results, please add it to the beginning of PATH in your profile.
一旦スルー。
GHCのインストールなど
$ stack setup
ここでトラブる。
configure: WARNING: configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly configure: error: in
/Users/yoshikiito/.stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2': configure: error: C compiler cannot create executables See
config.log' for more detailsError: Error encountered while configuring GHC with /Users/yoshikiito/.stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/Users/yoshikiito/.stack/programs/x86_64-osx/ghc-8.0.2/ run in /Users/yoshikiito/.stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/
ここで指定されたconfig.logの中身を見てみると、
$ sudo xcodebuild -license
しろと書いてあるので実行。
ライセンス条項に同意したのち、再度$stack setup
を行うことで、インストールが完了した。
いちおう参考:c++ - Haskell Stack Setup - Can't Recognize CPP Program - Stack Overflow
1.3 REPLとスクリプトの実行
対話的な実行環境REPL(Read-Eval-Print Loop)
ghciはStackから起動する。
$stack ghci
各種commandは本を参照。
ファイルに書いたスクリプトを直接実行
$ stack runghc hello.hs
今回の勉強時間 1時間30分
累計勉強時間 19時間13分