Re: defining (-> Bool) as a set

2002-04-23 Thread Hal Daume III
Yeah, I realized that right after I sent the email (I was composing "on the fly" and not copy-and-pasting). I think the main reason I wrote it as an explicit lambda expression rather than just single = (==) was because I wanted it to parallel the other definitions. IMO, the preferred way to writ

Re: defining (-> Bool) as a set

2002-04-23 Thread Christian Sievers
Hal Daume III wrote: > I'd like to be able to define something like > single x = \y -> if x == y then True else False Just a note on style: it always hurts me to see something like if term then True else False -- this is just the same as 'term'. So you could say single x = \y -> x==y

RE: defining (-> Bool) as a set

2002-04-22 Thread Simon Peyton-Jones
MAIL PROTECTED]] | Sent: 23 April 2002 01:30 | To: Jorge Adriano | Cc: Haskell Mailing List | Subject: Re: defining (-> Bool) as a set | | | Yeah, both options suggested are valid, of course. But I | really don't want to have a constructor and I'm using Edison | where Coll is d

Re: defining (-> Bool) as a set

2002-04-22 Thread Hal Daume III
Yeah, both options suggested are valid, of course. But I really don't want to have a constructor and I'm using Edison where Coll is defined something like: class Coll c e where empty :: c e insert :: c e -> e -> c e etc., which precludes the fun dep solution. - Hal -- Hal Daume III "Co

Re: defining (-> Bool) as a set

2002-04-22 Thread Jorge Adriano
> 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 This is way bette

Re: defining (-> Bool) as a set

2002-04-22 Thread Jorge Adriano
On Monday 22 April 2002 23:31, Hal Daume III wrote: > 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 > > an

Re: defining (-> Bool) as a set

2002-04-22 Thread Pixel
Hal Daume III <[EMAIL PROTECTED]> 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

defining (-> Bool) as a set

2002-04-22 Thread Hal Daume III
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 and the like However, this seems to be impossible. Is this the type