Data/Typeable/Uniplate instances for GHC types
Neil Mitchell
ndmitchell at gmail.com
Sat Jul 19 08:13:59 EDT 2008
Hi
> I think I've figured out what is going on: this technique simply
> doesn't work as well as we might hope it would! Here's why:
>
> While you ignore the explicit parameter, in practice there's an
> implicit dictionary parameter that is actually being used in res
> (Data/Typeable). At first sight, that might sound okay -we want a caf per
> type after all- but what happens is that we get *a caf per dictionary
> parameter* instead.
My tests show that is wrong. Inserting a trace around the type map
creation shows it is only called twice, with Company/Salary and
Salary/Salary. Profiling shows much the same result.
> Try this variation of the Paradise benchmark data:
>
> genCom :: Company
> genCom = C $ take 100000 $ cycle
> [D "Research" laemmel [PU joost, PU marlow],
> D "Strategy" blair []]
I did, and Uniplate underperforms. I'm not entirely sure why this is
yet, but my thoughts are kind of drifting towards a space leak, but I
do need to track it down. It seems as you increase the size of the
expressions the PlateData technique performs worse at queries.
> Am I on the right track here?
My guess is no - I think in Uniplate the CAF inside an instance trick
works. But you have certainly found _something_ ...
Thanks
Neil
More information about the Cvs-ghc
mailing list