<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On 13/03/2007, at 18:25, John Meacham wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">once we have ordNub, we can create lots of RULES like the following</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">{-# RULES "nub/ordNub" nub = ordNub :: [String] -&gt; [String] #-}<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">{-# RULES "nub/ordNub" nub = ordNub :: [Int] -&gt; [Int] #-}<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">{-# RULES "nub/ordNub" nub = ordNub :: [Integer] -&gt; [Integer] #-}<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">actually, we probably want one that uses IntMap for ints. it is</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">signifigantly faster.</FONT></P> </BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>very nice idea!</DIV><BR><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">I don't suppose there is a way to match a RULE to a class constraint? I</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">don't see how it would be implemented in any easy way since classes get</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">desugared away pretty early... but it would be an interesting feature..</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">{-# RULES "nub/ordNub" forall (a::*) . Ord a =&gt; nub = ordNub :: [a] -&gt; [a] #-}<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Monaco" size="2" style="font: 10.0px Monaco">or something...</FONT></P> </BLOCKQUOTE></DIV><BR><DIV>I think yes, the right syntax would be something like:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">{-# RULES "nub/ordNub" forall (x::Ord a =&gt; a). nub x = ordNub x #-}</SPAN></FONT></BLOCKQUOTE><BR><DIV>But hopefully someone else will confirm.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Also, what happens if the general Ord rule is added. Is it possible to convince GHC to use the more specific rule for Int before the general one?</DIV></BODY></HTML>