+rep_sig (L loc (TypeSig nm ty)) = rep_proto nm ty loc
+rep_sig (L _ (GenericSig nm _)) = failWithDs msg
+ where msg = vcat [ ptext (sLit "Illegal default signature for") <+> quotes (ppr nm)
+ , ptext (sLit "Default signatures are not supported by Template Haskell") ]
+
+rep_sig (L loc (InlineSig nm ispec)) = rep_inline nm ispec loc
+rep_sig (L loc (SpecSig nm ty ispec)) = rep_specialise nm ty ispec loc
+rep_sig _ = return []
+
+rep_proto :: Located Name -> LHsType Name -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_proto nm ty loc
+ = do { nm1 <- lookupLOcc nm
+ ; ty1 <- repLTy ty
+ ; sig <- repProto nm1 ty1
+ ; return [(loc, sig)]
+ }
+
+rep_inline :: Located Name
+ -> InlinePragma -- Never defaultInlinePragma
+ -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_inline nm ispec loc
+ = do { nm1 <- lookupLOcc nm
+ ; ispec1 <- rep_InlinePrag ispec
+ ; pragma <- repPragInl nm1 ispec1
+ ; return [(loc, pragma)]
+ }
+
+rep_specialise :: Located Name -> LHsType Name -> InlinePragma -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_specialise nm ty ispec loc
+ = do { nm1 <- lookupLOcc nm
+ ; ty1 <- repLTy ty
+ ; pragma <- if isDefaultInlinePragma ispec
+ then repPragSpec nm1 ty1 -- SPECIALISE
+ else do { ispec1 <- rep_InlinePrag ispec -- SPECIALISE INLINE
+ ; repPragSpecInl nm1 ty1 ispec1 }
+ ; return [(loc, pragma)]
+ }
+
+-- Extract all the information needed to build a TH.InlinePrag
+--
+rep_InlinePrag :: InlinePragma -- Never defaultInlinePragma
+ -> DsM (Core TH.InlineSpecQ)
+rep_InlinePrag (InlinePragma { inl_act = activation, inl_rule = match, inl_inline = inline })
+ | Just (flag, phase) <- activation1
+ = repInlineSpecPhase inline1 match1 flag phase
+ | otherwise
+ = repInlineSpecNoPhase inline1 match1
+ where
+ match1 = coreBool (rep_RuleMatchInfo match)
+ activation1 = rep_Activation activation
+ inline1 = case inline of
+ Inline -> coreBool True
+ _other -> coreBool False
+ -- We have no representation for Inlinable