data Set a = Set [a]
member xs x = elem x xs
subset xs ys = and (map (member ys) xs)
instance (Eq a) => Eq (Set a) where
(Set xs) == (Set ys) = (subset xs ys) && (subset ys xs)
class Ord a => Comparable a where
cmp :: a -> a -> String
cmp x y
| x == y = "eq"
| otherwise = "neq"
instance Comparable a => Comparable (Set a) where
cmp (Set xs) (Set ys)
| (Set xs) == (Set ys) = "same"
| otherwise = "different"
I'm getting the following error:
Could not deduce (Ord (Set a)) arising from the superclasses of an instance declaration from the context (Comparable a) bound by the instance declaration for ‘Comparable (Set a)’
I'd like to know what the error is? Thanks.