2
我試圖加載下面的程序基本程序加載失敗(哈斯克爾)
gcd a b = if b == 0
then a
else gcd b (rem a b)
但我得到的錯誤
Prelude> :l euclidean.hs
[1 of 1] Compiling Main (euclidean.hs, interpreted)
euclidean.hs:3:8:
Ambiguous occurrence `gcd'
It could refer to either `Main.gcd', defined at euclidean.hs:1:0
or `Prelude.gcd', imported from Prelude
Failed, modules loaded: none.
我從gcd
改變了函數名main
和我
Couldn't match expected type `IO t'
against inferred type `a -> a -> a'
In the expression: main
When checking the type of the function `main'
Failed, modules loaded: none.
我不明白這一點。我在這裏使用workshop步驟。
不要使用製表符作爲縮進。 – 2012-02-21 07:25:06
@ MatveyB.Aksenov爲什麼會有特定的原因? – yayu 2012-02-21 18:31:04
Haskell中的選項卡被定義爲8個空格。這可能不是您的(或您的協作者)編輯器顯示它們的方式,這會導致混淆錯誤。請參閱http://stackoverflow.com/questions/1269888/invisible-identation-error-in-haskell-caused-load-fail-in-ghci或http://stackoverflow.com/questions/1694097/haskell-compiler-error不在範圍內或幾十個類似的帖子在這裏。 – 2012-02-21 23:22:00