2
私は次のプログラム小学校プログラムは(ハスケル)のロードに失敗し
gcd a b = if b == 0
then a
else gcd b (rem a b)
をロードしようとしています。しかし、私は、私はgcd
からmain
に関数名を変更し、私が得る
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.
エラーが出ます
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のステップを使用しています。
インデントとしてタブを使用しないでください。 –
@ MatveyB.Aksenov具体的な理由はありますか? – yayu
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を参照してください。スコープがない、または数十もの類似の投稿がここにあります。 –