Cost of Overloading vs. HOFs

Stefan O'Rear stefanor at
Fri May 4 18:36:23 EDT 2007

On Fri, May 04, 2007 at 09:02:03PM +0100, Neil Mitchell wrote:
> Hi Adrian
> >The GHC users guide says overloading "is death to performance if
> >left to linger in an inner loop" and one thing I noticed while
> >playing about with the AVL lib was that using a HOF and passing
> >the (overloaded) compare function as an explicit argument at the
> >start seemed to give noticable a performance boost (compared with
> >dictionary passing presumably).
> >
> >I'm not sure why that should be, but has anyone else noticed this?
> A HOF is one box, the Ord dictionary is an 8-box tuple containing HOF
> boxes. When you invoke compare out of Ord, you are taking something
> out of the tuple, whereas when you use the HOF its directly there.
> This is also the reason you get a performance decrease moving from a
> 1-element class to a 2-element class.

What ever happened to OccurAnal?


More information about the Glasgow-haskell-users mailing list