我有GHCi,版本7.8.3.我想计算sqrt项的总和,它可以被10整除.
如果我写[ 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) …Run Code Online (Sandbox Code Playgroud)