: 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 defined something like
| 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 defined something like:
|
| class Coll c e where
| empty :: c e
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
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 write
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
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
and the like
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 better than my
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