1
什麼是錯的:爲什麼不能哈斯克爾函數返回一個列表
partin a = [floor a, a-floor a]
錯誤:
<interactive>:342:1: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show Ordering -- Defined in ‘GHC.Show’
instance Show Integer -- Defined in ‘GHC.Show’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
...plus 22 others
...plus 16 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In a stmt of an interactive GHCi command: print it
這是在說打印的東西,但你不顯示你如何打印東西。請顯示你正在做的事情的其餘部分。 – dfeuer
其實當我做「part a = a - floor a」也是同樣的錯誤。代碼只包含這個函數 –
他只是在GHCi提示符處輸入'part something',按照簽名行「在交互式GHCi命令的語句中:'打印它」。 – HTNW