我做的:类型的错误
Prelude> "sone" ++ "otehr"
"soneotehr"
但这样的代码:
addOneToElement :: [a] -> [a]
addOneToElement element = element ++ "next"
main = do
let s = addOneToElement("some")
putStrLn s
产生这样的输出:
all_possible_combinations.hs:22:37:
Couldn't match expected type `a' against inferred type `Char'
`a' is a rigid type variable bound by
the type signature for `addOneToElement'
at all_possible_combinations.hs:21:20
Expected type: [a]
Inferred type: [Char]
In the second argument of `(++)', namely `"next"'
In the expression: element ++ "next"
为什么我得到这个错误,我怎么能解决它?
此外,你可以(也应该,这是毫无意义和困惑)放弃功能调用的parens。 – delnan 2010-10-18 11:40:26