On Mon, Mar 20, 2006 at 12:09:41PM -0000, Simon Peyton-Jones wrote: > Definitely not at present, and I see no easy way to implement it. > > RULES are implemented by simple matching in Core. A call to nub will > have an Eq dictionary, but Core knows nothing of instance > declarations, and has no clue how to make an Ord dictionary. But an > Ord dictionary is what you want on the RHS of the rule. > > The type checker, on the other hand, knows about dictionary > construction, but nothing about RULES.
I suspected this was the case. Perhaps it could be solved with something like rule schemes, where a RULES pragma defines a template that is instantiated as new types that meet certain criteria are introduced. so a RULE with a class constraint would actually not be a single rule, but be copied and instantiated every time a new instance is declared at the new type. Something like this might also be useful for writing rules that apply to all built in C numeric types for instance.. not sure how much demand there is for something like this though. I have a sort of hack in jhc to write rules that apply to any type that maps directly to a C integral type for basic numeric rules. but it isn't user extensible in any way. (other than by adding new primitive numeric types that is) John -- John Meacham - ⑆repetae.net⑆john⑈ _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users