0
如何解決此錯誤並使我的代碼有效?與預期類型不符
我的數據類型:
data ID x = ID ((x, Mark), [ ID x ])
data Mark = Marked | Unmarked
顯示實例:
instance Show a => Show (ID a) where
show t = go " " t where
go aP (ID ((x, Marked), z)) =
aP ++ x ++ "\n"
錯誤:
Couldn't match expected type `[Char]' against inferred type `a'
`a' is a rigid type variable bound by
the instance declaration at Dictionary.hs:117:23
Expected type: ID [Char]
Inferred type: ID a
In the second argument of `go', namely `t'
In the expression: go "" t
Failed, modules loaded: none.
你能描述你希望你的秀ID例如做什麼? – Sarah 2012-04-21 10:22:48
@Sarah我試圖展示這棵樹。但是,對於這種情況,我將數字存儲爲字符。看到樹,看看http://stackoverflow.com/questions/10244343/visiting-each-node – john 2012-04-21 10:24:47
執行'go'與這個問題相關 – huon 2012-04-21 10:25:57