defining (-> Bool) as a set

Hal Daume III hdaume@ISI.EDU
Mon, 22 Apr 2002 17:29:47 -0700 (PDT)


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

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Tue, 23 Apr 2002, Jorge Adriano wrote:

> 
> > 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 solution... 
> 
> I had never used multi-parameter classes before, so I forgot the functional 
> dependency (right name? the "|ce->e"), and there was obviously no need for my 
> extra constructor.
> 
> J.A.
>