就像標題所示,我在使用Haskell時打印符號代碼及其相應符號時遇到了一些麻煩......我現在所擁有的是:在Haskell中使用遞歸打印出符號代碼及其相應符號
import Data.Char
import Debug.Trace
foo z | trace ("Symbolcode " ++ show z ++ " is " ++ (chr z)) False = undefined
foo z = if (z <= 128)
then foo (z+1)
else show "All done."
...我得到這樣一個錯誤:
Couldn't match expected type `[Char]' with actual type `Char'
In the return type of a call of `chr'
In the second argument of `(++)', namely `(chr z)'
In the second argument of `(++)', namely `" is " ++ (chr z)'
什麼我做錯了,有沒有這樣做(例如不使用跟蹤模塊)的更簡單的方法?
'main = putStrLn ['\ 128'..]''? –