ch01::RealWorldHaskell
amazon:Real World Haskellを購入。
原著は持っているんですがやはり日本語で読めるのはありがたいです。
とりあえずsicpマラソンも3章まで(logを残してませんが)終わったのでこちらを先に読み進めます。
amazon:プログラミングHaskellももうすぐ発売だし暫く(年末)はHaskellまみれになる予感。
ex.1-1
ghciから:setコマンドで型情報を表示、略。
Prelude> :set +t Prelude> 5 + 8 13 it :: Integer ... (略
ex.1-2
ghciのhelp表示は:?をタイプ。
Prelude> let x = 1 Prelude> :show bindings x :: Integer = _ Prelude> x 1 Prelude> :show bindings it :: Integer = 1 x :: Integer = 1 Prelude>
let x = 1 でlispチックにxを定義。定義直後の:show bindingsではxはワイルドカード(_)になっている。
xを評価したらxは1で表示され、最後に評価された式の結果を保持する特殊変数(it)ができる模様。
ex.1-3
-- ex.1.3 main = interact wordCount where wordCount input = show (length (words input)) ++ "\n"
ex.1-4
-- ex.1.4 main = interact wordCount where wordCount input = show (length input) ++ "\n"