change to deriving in 6.7 ??

Isaac Dupree isaacdupree at charter.net
Wed Aug 22 08:40:41 EDT 2007


Neil Mitchell wrote:
> Hi
> 
>> Thanks for the tips, Isaac.  I fixed my Ord decl.  Too bad about the
>> run-time time & space overhead.  I guess that's not fixable.  Perhaps Simon
>> will decide to follow Pepe's suggestion of liberal deriving when
>> UndecidableInstances enabled.
> 
> If you implement compare, isn't everything else simply a small
> constant over compare? And thats only if the optimiser doesn't pick up
> that constant and throw it away.
> 
> In general, I think if you implement compare in Ord, you are likely to
> end up with best (or very near best) performance.

It'll probably only be a significant difference if (f a) or (g a) has an 
unusual Ord instance that has rather different implementations of the 
different members (<), (compare) etc.  Which probably never actually 
happens.

Implementing compare likely needs to make one more comparison somewhere, 
versus (<) etc. (unless the optimizer is really good).  Usually compare 
is the nicest anyway.

Isaac




More information about the Cvs-ghc mailing list