1
我想寫一個顯示實例來顯示格式良好的公式,但在模仿完整的語法後,我仍然面臨如下的錯誤。Haskell:顯示實例歧義
Hugs> :load "C:\\Users\\Devil\\Desktop\\CASESTUDY1.hs"
ERROR file:.\CASESTUDY1.hs:15 - Ambiguous variable occurrence "show"
*** Could refer to: CASESTUDY1.show Hugs.Prelude.show
下面是我的.hs文件包含數據類型和相關show實例的內容。
module CASESTUDY1
where
data Wff = VAR String
| NEG Wff
| AND Wff Wff
| OR Wff Wff
| IMPL Wff Wff
instance Show Wff where
show (VAR x) = x
show (NEG x) = "~" ++ show(x)
show (AND x y) = "(" ++ show(x) ++ "^" ++ show(y) ++ ")"
show (OR x y) = "(" ++ show(x) ++ "v" ++ show(y) ++ ")"
show (IMPL x y) = "(" ++ show(x) ++ "-->" ++ show(y) ++ ")"
非常感謝Dacto,這是這麼久以來我感動哈斯克爾..謝謝你非常非常... – 2013-02-13 08:58:42
不用擔心,玩得開心! – Dacto 2013-02-13 09:00:13