Data/Typeable/Uniplate instances for GHC types

Simon Peyton-Jones simonpj at microsoft.com
Wed Jul 16 04:39:14 EDT 2008


| > Neil Mitchell tells me that he and Simon PJ are in favour of adding
| > instances for Data, Typeable, and Uniplate for many of the datatypes used
| > inside GHC.  I agree that this should certainly be done for the external
| > interface of GHC, i.e., core-plugins and GHC API.  Here they could be done
| > without introducing new dependencies to GHC itself, therefore are
| > uncontroversial.
|
| I don't know enough about Uniplate to make a judgement on that point,
| so I'll just pipe up and say that having Data/Typeable instances for
| Expr, Binds and friends would be of much benefit to the GHC plugins
| project. I've actually already written my own instances and put them
| straight into CoreSyn.hs on the plugins branch, but having them
| available via an explicit import is probably a better approach.

You can implement Uniplate on top of Data/Typeable.  (It's slightly slower than giving Uniplate instances directly, but if my memory serves, not a lot. See Neil's theis.)  So you can think of Uniplate/Biplate as a rather nice API for generic programming, but one that shares a common set of instances underneath. I'll all for having Data/Typeable instances for the main GHC types, and a Uniplate API available on top.

Simon



More information about the Cvs-ghc mailing list