{- starter program for Assignment 8, CSE 341, Winter 2003 simplifying set expressions in Haskell -} union :: Eq a => [a] -> [a] -> [a] -- write your union function here -- the type says that it takes a list of a's, which must be a type -- that supports equality tests -- -- the following definition of union is wrong -- it's just to get Haskell -- to accept this program union x y = [] -- also write declarations and definitions for intersect and difference -- here is a partial definition of the SetExpr data type -- you just need to add elements for Intersect and Difference data SetExpr = Set [Integer] | Var String | Union SetExpr SetExpr deriving (Eq,Show,Read) -- here is the type declaration for set_simplify, and an (incorrect) -- definition (all this version does is simplify an expression to itself) set_simplify :: SetExpr -> SetExpr set_simplify s = s -- here are some functions to run test cases on set_simplify -- (you'll need to add additional tests) t1 :: SetExpr t1 = set_simplify (Set [1,3]) -- doesn't simplify any further t2 :: SetExpr t2 = set_simplify (Union (Var "x") (Var "x")) -- should simplify to Var "x" t3 :: SetExpr t3 = set_simplify (Union (Var "x") (Var "y")) -- doesn't simplify any further