Haskell(2)とりあえずハローワールド

hello.hsファイル

main = putStrLn "hello, world."

これをコンパイルしてみる。

C:\ghc>ghc hello.hs -o hello

hello.exeができます。あとは実行。

C:\ghc>hello
hello, world.

main

main = ...

でmain関数(アクション?)を定義します。'='の右側がmain関数での動作。

putStrLn

put string lineです。引数に当てられた文字列プラス改行を出力。