在使用GHCi的Haskell中,有一種加載文件的方法,例如下面的文件,它允許您測試具有綁定的方法。Haskell:GHCi儘可能加載,而不是失敗或錯誤
使用案例:試圖測試我的模塊的一部分,而其餘部分的骨架代碼。 (爲不具有XY問題)
module X (methodA, methodB, methodC) where
methodA :: String->String
methodA name = "Hello " ++ name
methodB :: Int -> String
methodC :: String -> String
這顯然輸出正確的錯誤:The type signature for ‘methodB’ lacks an accompanying binding
。 例如,我想要類似於下面的內容來工作。
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Prelude> :l example.hs
[1 of 1] Compiling X (example.hs, interpreted)
example.hs:6:1: error:
The type signature for ‘methodB’ lacks an accompanying binding
example.hs:8:1: error:
The type signature for ‘methodC’ lacks an accompanying binding
Failed, modules loaded: none.
Prelude> methodA "jamesmstone"
<interactive>:2:1: error:
Variable not in scope: methodA :: [Char] -> t