2 % (c) The AQUA Project, Glasgow University, 1996
4 \section[PprEnv]{The @PprEnv@ type}
7 #include "HsVersions.h"
14 pCon, pLit, pMajBndr, pMinBndr, pOcc, pPrim, pSCC, pStyle,
15 pTy, pTyVarB, pTyVarO, pUVar, pUse
23 import Unique ( Unique )
24 import UniqFM ( emptyUFM, UniqFM )
26 #if __GLASGOW_HASKELL__ >= 202
27 import {-# SOURCE #-} Type ( GenType )
28 import {-# SOURCE #-} TyVar ( TyVar )
29 import {-# SOURCE #-} Id ( Id )
30 import Outputable ( PprStyle )
31 import Literal ( Literal )
32 import Usage ( GenUsage, SYN_IE(Usage) )
33 import {-# SOURCE #-} PrimOp (PrimOp)
34 import {-# SOURCE #-} CostCentre ( CostCentre )
39 For tyvars and uvars, we {\em do} normally use these homogenized
40 names; for values, we {\em don't}. In printing interfaces, though,
41 we use homogenized value names, so that interfaces don't wobble
42 uncontrollably from changing Unique-based names.
45 data PprEnv tyvar uvar bndr occ
46 = PE PprStyle -- stored for safe keeping
48 (Literal -> Doc) -- Doing these this way saves
49 (Id -> Doc) -- carrying around a PprStyle
53 (tyvar -> Doc) -- to print tyvar binders
54 (tyvar -> Doc) -- to print tyvar occurrences
56 (uvar -> Doc) -- to print usage vars
58 (bndr -> Doc) -- to print "major" val_bdrs
59 (bndr -> Doc) -- to print "minor" val_bdrs
60 (occ -> Doc) -- to print bindees
62 (GenType tyvar uvar -> Doc)
63 (GenUsage uvar -> Doc)
69 -> Maybe (Literal -> Doc)
71 -> Maybe (PrimOp -> Doc)
72 -> Maybe (CostCentre -> Doc)
73 -> Maybe (tyvar -> Doc)
74 -> Maybe (tyvar -> Doc)
75 -> Maybe (uvar -> Doc)
76 -> Maybe (bndr -> Doc)
77 -> Maybe (bndr -> Doc)
79 -> Maybe (GenType tyvar uvar -> Doc)
80 -> Maybe (GenUsage uvar -> Doc)
81 -> PprEnv tyvar uvar bndr occ
83 -- you can specify all the printers individually; if
84 -- you don't specify one, you get bottom
86 initPprEnv sty l d p c tvb tvo uv maj_bndr min_bndr occ ty use
101 demaybe Nothing = bottom
104 bottom = panic "PprEnv.initPprEnv: unspecified printing function"
107 initPprEnv sty pmaj pmin pocc
108 = PE (ppr sty) -- for a Literal
109 (ppr sty) -- for a DataCon
110 (ppr sty) -- for a PrimOp
111 (\ cc -> text (showCostCentre sty True cc)) -- CostCentre
113 (ppr sty) -- for a tyvar
114 (ppr sty) -- for a usage var
116 pmaj pmin pocc -- for GenIds in various guises
118 (ppr sty) -- for a Type
119 (ppr sty) -- for a Usage
124 pStyle (PE s _ _ _ _ _ _ _ _ _ _ _ _) = s
125 pLit (PE _ pp _ _ _ _ _ _ _ _ _ _ _) = pp
126 pCon (PE _ _ pp _ _ _ _ _ _ _ _ _ _) = pp
127 pPrim (PE _ _ _ pp _ _ _ _ _ _ _ _ _) = pp
128 pSCC (PE _ _ _ _ pp _ _ _ _ _ _ _ _) = pp
130 pTyVarB (PE _ _ _ _ _ pp _ _ _ _ _ _ _) = pp
131 pTyVarO (PE _ _ _ _ _ _ pp _ _ _ _ _ _) = pp
132 pUVar (PE _ _ _ _ _ _ _ pp _ _ _ _ _) = pp
134 pMajBndr (PE _ _ _ _ _ _ _ _ pp _ _ _ _) = pp
135 pMinBndr (PE _ _ _ _ _ _ _ _ _ pp _ _ _) = pp
136 pOcc (PE _ _ _ _ _ _ _ _ _ _ pp _ _) = pp
138 pTy (PE _ _ _ _ _ _ _ _ _ _ _ pp _) = pp
139 pUse (PE _ _ _ _ _ _ _ _ _ _ _ _ pp) = pp