On Wed, Jun 04, 2003 at 01:21:00PM +0100, Graham Klyne wrote: > There is a recurring difficulty I'm having using multiparameter classes. > > Most recently, I have a class Rule: > [[ > class (Expression ex, Eq (rl ex)) => Rule rl ex where > ... > ]] > > Which I wish to instantiate for a type GraphClosure via something like: > [[ > instance (Label lb, LDGraph lg lb) => Expression (lg lb) where > ... > > data (Label lb, LDGraph lg lb) => GraphClosure lg lb = ... > > instance Rule GraphClosure (NSGraph RDFLabel) where > ... > > ]] > ... > I think that what I really *want* to do here is change the kind of > GraphClosure to be (* -> *) rather than (* -> * -> *). But if I try this: > > [[ > data (Label lb, LDGraph lg lb) => GraphClosure (lg lb) = ... > ]] > a syntax error is reported by Hugs and GHC.
You haven't quite shown enough of your code. One thing you might consider is dropping the context from the definition of the GraphClosure type. Class contexts in data declarations end up being largely useless, anyway, since the dictionary is never actually used for anything. (There was a thread a few years ago about this.) You could then write > data GraphClosure lglb = ... But this only works if the definition of GraphClosure only uses (lg lb), not the individual pieces. Peace, Dylan
pgp00000.pgp
Description: PGP signature