Haskell : Show instance Ambiguity -
i trying write show instance display formed formula after miming whole syntax still facing same error below.
hugs> :load "c:\\users\\devil\\desktop\\casestudy1.hs" error file:.\casestudy1.hs:15 - ambiguous variable occurrence "show" *** refer to: casestudy1.show hugs.prelude.show below content of .hs file include info type , related show instance .
module casestudy1 info wff = var string | neg wff | , wff wff | or wff wff | impl wff wff instance show wff 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) ++ ")"
in haskell, whitespace important. need indent show's belong instance of show.
instance show wff show (var x) = show 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 ++ ")" also, not need parenthesis pass parameters show. show(x) should show x.
if learning haskell recommend these exceptional resources:
learn haskell great good real world haskell haskell
No comments:
Post a Comment