instance == (Set a) | Eq a\r
where (==) s1 s2 = isSubset s1 s2 && isSubset s2 s1\r
\r
-powerSet :: (Set a) -> Set (Set a)\r
-powerSet (Set a) = Set [(Set x) \\ x <- powerSet2 a]\r
-where\r
- powerSet2 :: [a] -> [[a]]\r
- powerSet2 [] = [[]]\r
- powerSet2 [e:xs] = (powerSet2 xs) ++ [[e:x] \\ x <- powerSet2 xs]\r
+powerSet :: (Set a) -> Set (Set a) | Eq a\r
+powerSet (Set []) = Set [(Set [])]\r
+powerSet (Set [e:xs]) = union (powerSet (Set xs))\r
+ (Set [union (Set [e]) x \\ x <- fromSet (powerSet (Set xs))])\r