2017-09-10 8 views
0

各コマンドの後にどのようにGHCiで結果の式のタイプを表示できますか?例えば 、代わりのGHCiでの各結果のタイプを表示

ghci> "hello" ++ " world" 
"hello world" 

は、私は、デフォルトでは、このような動作を提供する他の言語の

ghci> "hello" ++ " world" 
"hello world" :: String 

または少なくとも

ghci> "hello" ++ " world" 
"hello world" :: [Char] 

REPLsを見てみたいです。しかし、私はそのような動作のためにproper ghci optionを見つけることができません。また、すべてのコマンドを実行した後にitのタイプを印刷するだけでOKです。しかし、各ghciコマンドの後にコマンドを呼び出す方法を見つけられませんでした。賢明なコマンド:let ... = ...には結果がありません(ただし、定義された変数の型を印刷するのが良いでしょう)。 各コマンドの後に自動的に結果のタイプを表示する方法は何ですか?

答えて

5

:set +tから.ghciを追加します。 documentationから

+t 
    Display the type of each variable bound after a statement is entered at the prompt. 
    If the statement is a single expression, then the only variable binding will be for 
    the variable ‘it’.