pprTypeForUser
) where
-#include "HsVersions.h"
-
import qualified GHC
import GHC ( TyThing(..) )
import Var
import Name
import Outputable
+import FastString
-- -----------------------------------------------------------------------------
-- Pretty-printing entities that we get from the GHC API
pprTyConHdr :: PrintExplicitForalls -> TyCon -> SDoc
pprTyConHdr _ tyCon
| Just (_fam_tc, tys) <- tyConFamInst_maybe tyCon
- = ptext keyword <+> ptext SLIT("instance") <+> pprTypeApp tyCon (ppr_bndr tyCon) tys
+ = ptext keyword <+> ptext (sLit "instance") <+> pprTypeApp tyCon tys
| otherwise
= ptext keyword <+> opt_family <+> opt_stupid <+> ppr_bndr tyCon <+> hsep (map ppr vars)
where
GHC.isFunTyCon tyCon = take (GHC.tyConArity tyCon) GHC.alphaTyVars
| otherwise = GHC.tyConTyVars tyCon
- keyword | GHC.isSynTyCon tyCon = SLIT("type")
- | GHC.isNewTyCon tyCon = SLIT("newtype")
- | otherwise = SLIT("data")
+ keyword | GHC.isSynTyCon tyCon = sLit "type"
+ | GHC.isNewTyCon tyCon = sLit "newtype"
+ | otherwise = sLit "data"
opt_family
- | GHC.isOpenTyCon tyCon = ptext SLIT("family")
+ | GHC.isOpenTyCon tyCon = ptext (sLit "family")
| otherwise = empty
opt_stupid -- The "stupid theta" part of the declaration
pprClassHdr :: PrintExplicitForalls -> GHC.Class -> SDoc
pprClassHdr _ cls =
let (tyVars, funDeps) = GHC.classTvsFds cls
- in ptext SLIT("class") <+>
+ in ptext (sLit "class") <+>
GHC.pprThetaArrow (GHC.classSCTheta cls) <+>
ppr_bndr cls <+>
hsep (map ppr tyVars) <+>
pprAlgTyCon :: PrintExplicitForalls -> TyCon -> (GHC.DataCon -> Bool)
-> (FieldLabel -> Bool) -> SDoc
pprAlgTyCon pefas tyCon ok_con ok_label
- | gadt = pprTyConHdr pefas tyCon <+> ptext SLIT("where") $$
+ | gadt = pprTyConHdr pefas tyCon <+> ptext (sLit "where") $$
nest 2 (vcat (ppr_trim show_con datacons))
| otherwise = hang (pprTyConHdr pefas tyCon)
2 (add_bars (ppr_trim show_con datacons))
ppr_tvs
| null qualVars = empty
- | otherwise = ptext SLIT("forall") <+>
+ | otherwise = ptext (sLit "forall") <+>
hsep (map ppr qualVars) <> dot
-- printing out the dataCon as a type signature, in GADT style
ppr_fields [ty1, ty2]
| GHC.dataConIsInfix dataCon && null labels
- = sep [pprParendBangTy ty1, ppr dataCon, pprParendBangTy ty2]
+ = sep [pprParendBangTy ty1, pprInfixName dataCon, pprParendBangTy ty2]
ppr_fields fields
| null labels
= ppr_bndr dataCon <+> sep (map pprParendBangTy fields)
| null methods =
pprClassHdr pefas cls
| otherwise =
- hang (pprClassHdr pefas cls <+> ptext SLIT("where"))
+ hang (pprClassHdr pefas cls <+> ptext (sLit "where"))
2 (vcat (map (pprClassMethod pefas) methods))
where
methods = GHC.classMethods cls
pprClassOneMethod :: PrintExplicitForalls -> GHC.Class -> Id -> SDoc
pprClassOneMethod pefas cls this_one
- = hang (pprClassHdr pefas cls <+> ptext SLIT("where"))
+ = hang (pprClassHdr pefas cls <+> ptext (sLit "where"))
2 (vcat (ppr_trim show_meth methods))
where
methods = GHC.classMethods cls
go x (eliding, so_far)
| Just doc <- show x = (False, doc : so_far)
| otherwise = if eliding then (True, so_far)
- else (True, ptext SLIT("...") : so_far)
+ else (True, ptext (sLit "...") : so_far)
add_bars :: [SDoc] -> SDoc
add_bars [] = empty
= hang doc 2 (char '\t' <> comment <+> loc)
-- The tab tries to make them line up a bit
where
- comment = ptext SLIT("--")
+ comment = ptext (sLit "--")