defining (-> Bool) as a set
Mon, 22 Apr 2002 23:16:41 -0700
[I think this sort of question would be better on the haskell-cafe
I don't think what you want can be done directly. It's the old
thing about not having lambdas at the type level. You want:
instance Eq a =3D> Coll (\x. x -> Bool) a where ...
and you just can't do that. You *can* abstract the second argument
instance Eq a =3D> Coll ((->) Bool) a where ...
but not the first. It's a well known shortcoming in Haskell, that you
partially apply type constructors, but you can't do argument
I know of no good solution. Adding type lambdas in their full glory
makes type inference pretty much impossible. What we'd like is
a compromise. Maybe someone can invent one. But take care.
The ground is littered with corpses.
| -----Original Message-----
| From: Hal Daume III [mailto:hdaume@ISI.EDU]=20
| 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=20
| really don't want to have a constructor and I'm using Edison=20
| 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 | email@example.com
| 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 =3D> Collection a (a -> Bool) where
| > > empty =3D (\x -> False)
| > > insert e f =3D (\x -> if x =3D=3D e then True else f x)
| > > member e f =3D f e
| > This is way better than my solution...
| > I had never used multi-parameter classes before, so I forgot the=20
| > functional
| > dependency (right name? the "|ce->e"), and there was=20
| obviously no need for my=20
| > extra constructor.
| > J.A.
| Haskell mailing list
| Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell