Fix Trac #3245: memoising typeOf
authorsimonpj@microsoft.com <unknown>
Fri, 18 Dec 2009 15:51:17 +0000 (15:51 +0000)
committersimonpj@microsoft.com <unknown>
Fri, 18 Dec 2009 15:51:17 +0000 (15:51 +0000)
commit2f01e7edb15fbb18e16b37dbada770c1b6db1528
tree71c24ae3d73870fd5386310f23735a71d297ef41
parentdf216b73ec9bdcca18e5265ea69da972e645c27a
Fix Trac #3245: memoising typeOf

The performance bug in #3245 was caused by computing the typeRep
once for each call of typeOf, rather than once for each dictionary
contruction.  (Computing TypeReps is reasonably expensive, because
of the hash-consing machinery.)

This is readily fixed by putting the TypeRep construction outside
the lambda.  (Arguably GHC might have worked that out itself,
but it involves floating something between a type lambda and a
value lambda, which GHC doesn't currently do. If it happens a lot
we could fix that.)
Data/Typeable.hs