-- Reference/prototype implementation for sets: module Sets (Set, empty, insert, isElem, union) where -- set === characteristic function data Set a = Set (a -> Bool) instance Show (Set a) where show s = "some set" empty :: Set a empty = Set (\e -> False) insert :: Eq a => a -> Set a -> Set a insert x (Set s) = Set (\y -> x==y || s y) isElem :: a -> Set a -> Bool isElem x (Set s) = s x union :: Set a -> Set a -> Set a union (Set s1) (Set s2) = Set (\x -> s1 x || s2 x)