我不明白为什么这不起作用。 我的数据类型如下:在过去的LOCHaskell类型与列表/元组构造的数据类型匹配错误
data IndexedTree a = Leaf [a] | Node [(IndexedTree a, a)]
first (x, _) = x
test :: IndexedTree a -> Bool
test (Leaf x) = True
test (Node (x:xs)) = test first(x)
收益率
Could not match expected type IndexedTree a0
with actual type (t0,t1)-> t0
。 我不明白为什么会发生这种情况,以及如何避免这种情况。
请注意,'Prelude'函数'fst'与您的'first'完全相同。 – Benesh