【发布时间】:2015-03-17 12:57:25
【问题描述】:
我有 GHCi,版本 7.8.3。我想计算可以被 10 整除的 sqrt 项的总和。
如果我写[ x | x <- [10..100], x `mod` 10 == 0] 或sum [sqrt x | x <- [10..100]] 是正确的。
但是如果我在显示错误的时候写sum [ sqrt x | x <- [10..100], x `mod` 10 == 0]:
'<interactive>:39:1:
No instance for (Show t0) arising from a use of ‘print’
The type variable ‘t0’ is ambiguous
Note: there are several potential instances:
instance Show Double -- Defined in ‘GHC.Float’
instance Show Float -- Defined in ‘GHC.Float’
instance (Integral a, Show a) => Show (GHC.Real.Ratio a)
-- Defined in ‘GHC.Real’
...plus 23 others
In a stmt of an interactive GHCi command: print it'
如何改命令,程序是否正确?
【问题讨论】:
标签: list haskell list-comprehension