GHCi

GHCiは対話的に操作できるインタプリタ。:help コマンドで使い方がわかる。

>ghci
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.4.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base-1.0 ... linking ... done.
Prelude> :help
 Commands available from the prompt:

                         evaluate/run 
   :add  ...         add module(s) to the current target set
   :browse [*]         display the names defined by 
   :cd                    change directory to 
   :def             define a command :
   :help, :?                   display this list of commands
   :info [ ...]          display information about the given names
   :load  ...        load module(s) and their dependents
   :module [+/-] [*] ...  set the context for expression evaluation
   :reload                     reload the current module set

   :set 

終了するには :quit。


関数の定義はできない。別途ファイルに保存して、:load コマンドで読み込む。

 Prelude> :l addone.hs
 Compiling Main             ( addone.hs, interpreted )
 Ok, modules loaded: Main.
 *Main> addOne 3
 4