我被困在这个问题上,而且我对 Haskell 很陌生,我试图用以下代码完成第一个欧拉问题:
main = putStrLn . show . sum $ [3,6..1000]:[5,10..1000]
这是错误的第一部分:
euler/1.hs:1:19:
No instance for (Show t0) arising from a use of `show'
The type variable `t0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
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 the first argument of `(.)', namely `show'
In the second argument of `(.)', namely `show . sum'
In the expression: putStrLn . show . sum