Would there be any problems if there were an artificial "<-" type constructor in Haskell which was basically:
type a <- b = b -> a but not a type synonym so you could define it to be instances of classes, but then those get applied "backwards" to ->? Okay, that made no sense. I'll try again. Type lambda = bad (undecidable). What about only type lambda on function types and not even type lambda; simply allow partial application to the second argument *only* on ->? This would solve my problem and I believe that of an earlier poster who wanted to define catamorphisms (I think; don't feel like checking), but couldn't because of this restriction. Is this still "too loose" to be made to work? -- Hal Daume III "Computer science is no more about computers | [EMAIL PROTECTED] than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Mon, 22 Apr 2002, Simon Peyton-Jones wrote: > Hal, > > [I think this sort of question would be better on the haskell-cafe > list.] > > 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 => Coll (\x. x -> Bool) a where ... > > and you just can't do that. You *can* abstract the second argument > of (->): > > instance Eq a => Coll ((->) Bool) a where ... > > but not the first. It's a well known shortcoming in Haskell, that you > can > partially apply type constructors, but you can't do argument > permutation. > > 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. > > Simon > > > | -----Original Message----- > | From: Hal Daume III [mailto:[EMAIL 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 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 PROTECTED] > | 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. > | > > | > | _______________________________________________ > | Haskell mailing list > | [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell > | > _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe