2
を再帰を使用して簡単な乗数の作成、GHCiのは、関数の型にエラーが発生しHaskellは:(式A)リテラルから生じる推測できませんでした「1」コンテキスト(ヌムA)から
mul :: Num a => a -> a -> a
mul a 1 = a
mul a n = a + mul a (n-1)
これは、エラーメッセージは、私はNum a
部分は必須ですので、私はのparamsをNumberオブジェクトを適用しなければならないと思います
Could not deduce (Eq a) arising from the literal ‘1’
from the context (Num a)
bound by the type signature for mul :: Num a => a -> a -> a
at es8.hs:44:8-27
Possible fix:
add (Eq a) to the context of
the type signature for mul :: Num a => a -> a -> a
In the pattern: 1
In an equation for ‘mul’: mul a 1 = a
Failed, modules loaded: none.
を受けました。
「Num」の代わりに「Integral」にする必要があります。「mul 3 2.5」の処理を検討してください。 –
'Integral'だけでは' mul 3 0'の問題は解決しません。 – chepner