17
使用GHCi時,我想知道如何在提示(重新)加載時使用-Wall
選項。來自GHCi提示的加載警告
例如,在與警衛所示的Haskell Programming Tips 例子3.3節如下:
-- Bad implementation:
fac :: Integer -> Integer
fac n | n == 0 = 1
| n /= 0 = n * fac (n-1)
-- Slightly improved implementation:
fac :: Integer -> Integer
fac n | n == 0 = 1
| otherwise = n * fac (n-1)
它說:「第一個問題是,它是幾乎不可能的編譯器檢查這樣的後衛是否詳盡,因爲警戒條件可能非常複雜(如果您使用-Wall選項,GHC會發出警告)。「
我知道我可以從命令行鍵入ghci -Wall some_file.hs
,但是一旦出現提示,我不確定如何檢查警告是否需要重新加載。
我似乎無法找到答案後嘗試Google!
在此先感謝!
你可以把它放到你的'.ghci'文件的便利。我有':set -Wall \ n:set -fno-warn-type-defaults \ n:set -fno-warn-unused-do-bind'來打開所有的煩人的警告。 –
如果您第一次設置「-Wall」,我認爲它也將保持設置以進行任何重新加載... –