IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

ghciの使い方

プロンプトを変える

:set prompt "foo>"

バンドされている情報を見る

:show bindings
foo>let x = 123
foo>let y = "abc"
foo>:show bindings
x :: Num t => t = _
y :: [Char] = _
foo>

ロードされているモジュールを確認する

:show module
foo>:l MyWebApp1.hs
[1 of 1] Compiling Main             ( MyWebApp1.hs, interpreted )
Ok, modules loaded: Main.
foo>:show modules
Main             ( MyWebApp1.hs, interpreted )
foo>

インポートされている情報を確認する

:show imports
foo>import Data.Set
foo>:show imports
import Data.Set
:module +*Main -- added automatically
foo>import Servant
foo>:show imports
import Data.Set
import Servant
:module +*Main -- added automatically
foo>

エディタを開く

:edit

言語拡張情報の確認

:show language
foo>:set -XConstraintKinds
foo>:show language
base language is: Haskell2010
with the following modifiers:
  -XConstraintKinds
  -XNoDatatypeContexts
  -XNondecreasingIndentation
foo>

main関数ではない関数をmainとして実行する

:main [foo] op1 op2 op3

historyファイルの場所

~/.ghc/ghci_history