命題論理実装してみようず

data Expr a =
    TRUE
  | FALSE
  | And (Expr a) (Expr a)
  | Or (Expr a) (Expr a)
  | Not (Expr a)
  | Base a

eval :: (t -> Bool) -> Expr t -> Bool
eval evalBase expr =
  case expr of
       TRUE -> True
       FALSE -> False
       Base base -> evalBase base
       And x y -> eval' x && eval' y
       Or x y -> eval' x || eval' y
       Not x -> not $ eval' x
  where eval' = eval evalBase