Skip to content

Commit b4856f9

Browse files
author
Simon Peyton Jones
committed
Do pretty-printing of TyThings via IfaceDecl (Trac #7730)
All the initial work on this was done fy 'archblob' (fcsernik@gmail.com); thank you! I reviewed the patch, started some tidying, up and then ended up in a huge swamp of changes, not all of which I can remember now. But: * To suppress kind arguments when we have -fno-print-explicit-kinds, - IfaceTyConApp argument types are in a tagged list IfaceTcArgs * To allow overloaded types to be printed with =>, add IfaceDFunTy to IfaceType. * When printing data/type family instances for the user, I've made them print out an informative RHS, which is a new feature. Thus ghci> info T data family T a data instance T Int = T1 Int Int data instance T Bool = T2 * In implementation terms, pprIfaceDecl has just one "context" argument, of type IfaceSyn.ShowSub, which says - How to print the binders of the decl see note [Printing IfaceDecl binders] in IfaceSyn - Which sub-comoponents (eg constructors) to print * Moved FastStringEnv from RnEnv to OccName It all took a ridiculously long time to do. But it's done!
1 parent da64c97 commit b4856f9

File tree

35 files changed

+1135
-917
lines changed

35 files changed

+1135
-917
lines changed

compiler/basicTypes/OccName.lhs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ module OccName (
102102
-- * Lexical characteristics of Haskell names
103103
isLexCon, isLexVar, isLexId, isLexSym,
104104
isLexConId, isLexConSym, isLexVarId, isLexVarSym,
105-
startsVarSym, startsVarId, startsConSym, startsConId
105+
startsVarSym, startsVarId, startsConSym, startsConId,
106+
107+
-- FsEnv
108+
FastStringEnv, emptyFsEnv, lookupFsEnv, extendFsEnv, mkFsEnv
106109
) where
107110
108111
import Util
@@ -117,6 +120,29 @@ import Data.Char
117120
import Data.Data
118121
\end{code}
119122

123+
%************************************************************************
124+
%* *
125+
FastStringEnv
126+
%* *
127+
%************************************************************************
128+
129+
FastStringEnv can't be in FastString becuase the env depends on UniqFM
130+
131+
\begin{code}
132+
type FastStringEnv a = UniqFM a -- Keyed by FastString
133+
134+
135+
emptyFsEnv :: FastStringEnv a
136+
lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a
137+
extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a
138+
mkFsEnv :: [(FastString,a)] -> FastStringEnv a
139+
140+
emptyFsEnv = emptyUFM
141+
lookupFsEnv = lookupUFM
142+
extendFsEnv = addToUFM
143+
mkFsEnv = listToUFM
144+
\end{code}
145+
120146
%************************************************************************
121147
%* *
122148
\subsection{Name space}
@@ -246,6 +272,9 @@ instance Data OccName where
246272
toConstr _ = abstractConstr "OccName"
247273
gunfold _ _ = error "gunfold"
248274
dataTypeOf _ = mkNoRepType "OccName"
275+
276+
instance HasOccName OccName where
277+
occName = id
249278
\end{code}
250279

251280

0 commit comments

Comments
 (0)