编程 haskell

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 16:46:44
编程haskell编程haskell编程haskelldataProp=ConstBool         &

编程 haskell
编程 haskell

编程 haskell
data Prop = Const Bool
            | Var Char
            | Not Prop
            | And Prop Prop
            | Or Prop Prop
            | Imply Prop Prop
            deriving Eq
                          
instance Show Prop where
    show (Const a) = "Const " ++ show a
    show (Var a) = show a
    show (And a b) = show a ++ " && " ++ show b
    show (Or a b) = show a ++ " || " ++ show b
    show (Not a) = "!(" ++ show a ++ ")"
    show (Imply a b) = show a ++ " => " ++ show b


试试看吧