import Ubiq
import IdLoop -- for paranoia checking
import TyLoop -- for paranoia checking
-import NameLoop -- for paranoia checking
-- friends:
-- (PprType can see all the representations it's trying to print)
import CStrings ( identToC )
import CmdLineOpts ( opt_OmitInterfacePragmas )
import Maybes ( maybeToBool )
-import NameTypes ( ShortName, FullName )
-import Outputable ( ifPprShowAll, isAvarop, interpp'SP )
+import Name ( isLexVarSym, isPreludeDefined, origName, moduleOf,
+ Name{-instance Outputable-}
+ )
+import Outputable ( ifPprShowAll, interpp'SP )
import PprStyle ( PprStyle(..), codeStyle, showUserishTypes )
import Pretty
import TysWiredIn ( listTyCon )
-- Some help functions
ppr_corner sty env ctxt_prec (TyConTy FunTyCon usage) arg_tys
- = ASSERT(length arg_tys == 2)
+ | length arg_tys == 2
+ = (if length arg_tys /= 2 then pprTrace "ppr_corner:" (ppCat (map (ppr_ty sty env ctxt_prec) arg_tys)) else id) $
+ ASSERT(length arg_tys == 2)
ppr_ty sty env ctxt_prec (FunTy ty1 ty2 usage)
where
(ty1:ty2:_) = arg_tys
-ppr_corner sty env ctxt_prec (TyConTy (TupleTyCon a) usage) arg_tys
- = ASSERT(length arg_tys == a)
+ppr_corner sty env ctxt_prec (TyConTy (TupleTyCon _ _ a) usage) arg_tys
+ = --ASSERT(length arg_tys == a)
+ (if (length arg_tys /= a) then pprTrace "ppr_corner:" (ppCat [ppInt a, ppInterleave ppComma (map (pprGenType PprDebug) arg_tys)]) else id) $
ppBesides [ppLparen, arg_tys_w_commas, ppRparen]
where
arg_tys_w_commas = ppIntersperse pp'SP (map (ppr_ty sty env tOP_PREC) arg_tys)
%* *
%************************************************************************
-ToDo; all this is suspiciously like getOccurrenceName!
+ToDo; all this is suspiciously like getOccName!
\begin{code}
showTyCon :: PprStyle -> TyCon -> String
pprTyCon :: PprStyle -> TyCon -> Pretty
pprTyCon sty FunTyCon = ppStr "(->)"
-pprTyCon sty (TupleTyCon arity) = ppBeside (ppPStr SLIT("Tuple")) (ppInt arity)
+pprTyCon sty (TupleTyCon _ name _) = ppr sty name
pprTyCon sty (PrimTyCon uniq name kind) = ppr sty name
-pprTyCon sty tycon@(DataTyCon uniq kind name tyvars ctxt cons derivings nd)
- = case sty of
- PprDebug -> pp_tycon_and_uniq
- PprShowAll -> pp_tycon_and_uniq
- _ -> pp_tycon
- where
- pp_tycon_and_uniq = ppBesides [pp_tycon, ppChar '.', pprUnique uniq]
- pp_tycon = ppr sty name
+pprTyCon sty tycon@(DataTyCon uniq name kind tyvars ctxt cons derivings nd)
+ = ppr sty name
pprTyCon sty (SpecTyCon tc ty_maybes)
= ppBeside (pprTyCon sty tc)
_ -> pp_user
where
pp_C = ppPStr op_name
- pp_user = if isAvarop op_name
+ pp_user = if isLexVarSym op_name
then ppBesides [ppLparen, pp_C, ppRparen]
else pp_C
\end{code}
= case (maybeAppTyCon ty) of
Nothing -> true_bottom
Just (tycon,_) ->
- if fromPreludeCore tycon
+ if isPreludeDefined tycon
then true_bottom
- else (False, fst (getOrigName tycon))
+ else (False, moduleOf (origName tycon))
true_bottom = (True, panic "getTypeString")
ppCat [ppPStr SLIT("type"), ppr sty n, ppIntersperse ppSP pp_tyvars,
ppEquals, ppr_ty sty lookup_fn tOP_PREC exp]
-pprTyCon sty@PprInterface this_tycon@(DataTyCon k n a vs ctxt cons derivings data_or_new) specs
+pprTyCon sty@PprInterface this_tycon@(DataTyCon u n k vs ctxt cons derivings data_or_new) specs
= ppHang (ppCat [pp_data_or_new,
pprContext sty ctxt,
ppr sty n,
= let
(_, _, con_arg_tys, _) = dataConSig con
in
- ppCat [pprNonOp PprForUser con, -- the data con's name...
+ ppCat [pprNonSym PprForUser con, -- the data con's name...
ppIntersperse ppSP (map (ppr_ty sty lookup_fn tYCON_PREC) con_arg_tys)]
ppr_next_con con = ppCat [ppChar '|', ppr_con con]
pp_NONE = ppPStr SLIT("_N_")
-pprTyCon PprInterface (TupleTyCon a) specs
+pprTyCon PprInterface (TupleTyCon _ name _) specs
= ASSERT (null specs)
- ppCat [ ppStr "{- Tuple", ppInt a, ppStr "-}" ]
+ ppCat [ ppStr "{- ", ppr PprForUser name, ppStr "-}" ]
pprTyCon PprInterface (PrimTyCon k n a kind_fn) specs
= ASSERT (null specs)