【发布时间】:2014-05-11 09:08:28
【问题描述】:
当我在 Haskell 中编译我的代码时,我得到了这个:
Couldn't match type '[Char]' with 'Car a1 [Char]'
Expected type: [Car a1 [Char]]
Actual type: [[Char]]
我是 Haskell 的新手,不知道这意味着什么。在过去的 45 分钟里,我一直在寻找答案,但在我的情况下没有找到任何帮助。
这是第一个错误:
Couldn't match expected type '[[Char]]'
with actual type 'Car [Char] t0'
In the pattern: Leaf a
In an equation for 'evaluation': evaluation (Leaf a) = a
这与它有问题的代码行有关。如果您希望我发布更多信息,请告诉我,谢谢。
evaluation (Leaf a) = a
evaluation (Breakpoint "j" []) = 0
evaluation (Breakpoint "j" x:xs) = evaluation (x) + evaluation (Breakpoint "j" xs)
【问题讨论】:
-
你能发布你试图编译的代码吗?
-
请发布具有构造函数
Leaf和Breakpoint的类型的定义,如果可以,请发布evaluation的类型签名。 -
我发现了问题所在。我正在创建自己的 sum 和 product 函数,它们已经在标准函数中声明并给了我这个错误。当我尝试更正代码时出现此错误。谢谢大家的时间。