我写了一个程序,haskell
但我从 ghci 得到了错误
这是源代码,我构建它,如果我有
p1 :: Prop
p1 = And (Var 'A') (Not (Var 'A'))
它将显示A && ~A
这是源代码
import Data.List
import Data.Char
data Prop = Const Bool |
Var Char |
Not Prop |
And Prop Prop |
Or Prop Prop |
Imply Prop Prop
deriving Eq
instance Show Prop where
show (Var Char) = show Char
show (Not Prop) = "(~" ++ show Prop ++ ")"
show (And Prop Prop) = "(" ++ show Prop ++ "&&" ++ show Prop ++ ")"
show (Or Prop Prop) = "(" ++ show Prop "||" ++ show Prop ++ ")"
show (Imply Prop Prop) = "(" ++ show Prop "=>" show Prop ++ ")"
我从 ghci 得到了两个主要错误......
Not in scope: data constructor `Char'
Not in scope: data constructor `Prop'
我是haskell的初学者,非常感谢。