编程 haskell

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/01 21:28:13
编程 haskell

编程 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


试试看吧