就像标题说的那样,我在使用 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)'
我做错了什么,有没有更简单的方法(例如不使用跟踪模块)?