Make template-haskell deriving work (kind of)

Doesn't yet work for mutually dependent data-types because of some weird TH bug in GHC.