+--------------------------
+trimThing :: Bool -> NameSet -> TyThing -> TyThing
+-- Trim off inessentials, for boot files and no -O
+trimThing th exports (ATyCon tc)
+ | not th && not (mustExposeTyCon exports tc)
+ = ATyCon (makeTyConAbstract tc) -- Note [Trimming and Template Haskell]
+
+trimThing _th _exports (AnId id)
+ | not (isImplicitId id)
+ = AnId (id `setIdInfo` vanillaIdInfo)
+
+trimThing _th _exports other_thing
+ = other_thing
+
+
+{- Note [Trimming and Template Haskell]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider (Trac #2386) this
+ module M(T, makeOne) where
+ data T = Yay String
+ makeOne = [| Yay "Yep" |]
+Notice that T is exported abstractly, but makeOne effectively exports it too!
+A module that splices in $(makeOne) will then look for a declartion of Yay,
+so it'd better be there. Hence, brutally but simply, we switch off type
+constructor trimming if TH is enabled in this module. -}