22 Apr
2002
22 Apr
'02
11:36 p.m.
Hal Daume III <hdaume@ISI.EDU> writes:
I'd like to be able to define something like
instance Eq a => Coll (-> Bool) a where empty = \_ -> False single x = \y -> if x == y then True else False union a b = \x -> a x || b x insert s x = \y -> x == y || s y
I don't know what Coll is, but the following is working: class Collection e ce | ce -> e where empty :: ce insert :: e -> ce -> ce member :: e -> ce -> Bool instance Eq a => Collection a (a -> Bool) where empty = (\x -> False) insert e f = (\x -> if x == e then True else f x) member e f = f e