请问您可以告诉我如何解决这个错误在我的代码?haskell中的高阶函数Error2
{--------------------- BINARY TO DECIMAL MENU ---------------}
functionBinToDecimal:: IO()
functionBinToDecimal= do
putStrLn("\n\tConvert Binary To Decimal\n")
putStrLn("----------------------------------------------------------\n")
putStrLn("\t\tEnter a binary number : ")
input<-getLine
let n=(read (reverse input))::String
let result = convertionFrom binaryToDec n
putStrLn(show result)
{----------------BINARY TO DECIMAL---------------------}
binaryToDec :: String -> Int
binaryToDec = foldr (\x s -> s * 2 + x) 0 . reverse . map charToInt
where charToInt x = if x == '0' then 0 else 1
conversionFrom :: (String -> Int) -> String -> Int
conversionFrom _ [] = 0
conversionFrom f (x:xs) = f x ++ conversionFrom f xs
错误
test.hs:28:27:
Couldn't match expected type `Int' with actual type `[a0]'
In the expression: f x ++ conversionFrom f xs
In an equation for `conversionFrom':
conversionFrom f (x : xs) = f x ++ conversionFrom f xs
旁注:它拼写为“转换”,而不是“转换”。 – dflemstr 2012-02-08 06:39:58
您**了解**错误信息的含义? [我昨天解释](http://stackoverflow.com/a/9177409/86622)如何阅读这种错误信息。 – dave4420 2012-02-08 07:59:12