2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[HsDecls]{Abstract syntax: global declarations}
6 Definitions for: @TyDecl@ and @ConDecl@, @ClassDecl@,
7 @InstDecl@, @DefaultDecl@ and @ForeignDecl@.
11 HsDecl(..), TyClDecl(..), InstDecl(..), RuleDecl(..), RuleBndr(..),
12 DefaultDecl(..), ForeignDecl(..), ForKind(..),
13 ExtName(..), isDynamicExtName, extNameStatic,
14 ConDecl(..), ConDetails(..),
15 BangType(..), getBangType,
16 DeprecDecl(..), DeprecTxt,
17 hsDeclName, instDeclName, tyClDeclName, tyClDeclNames, tyClDeclSysNames,
18 isClassDecl, isSynDecl, isDataDecl, isIfaceSigDecl, countTyClDecls,
19 mkClassDeclSysNames, isIfaceRuleDecl, ifaceRuleDeclName,
20 getClassDeclSysNames, conDetailsTys
23 #include "HsVersions.h"
26 import HsBinds ( HsBinds, MonoBinds, Sig(..), FixitySig(..) )
27 import HsExpr ( HsExpr )
29 import PprCore ( pprCoreRule )
30 import HsCore ( UfExpr, UfBinder, HsIdInfo, pprHsIdInfo,
31 eq_ufBinders, eq_ufExpr, pprUfExpr
33 import CoreSyn ( CoreRule(..) )
34 import BasicTypes ( NewOrData(..) )
35 import CallConv ( CallConv, pprCallConv )
38 import Name ( NamedThing )
39 import FunDeps ( pprFundeps )
40 import Class ( FunDep, DefMeth(..) )
41 import CStrings ( CLabelString, pprCLabelString )
43 import SrcLoc ( SrcLoc )
47 %************************************************************************
49 \subsection[HsDecl]{Declarations}
51 %************************************************************************
55 = TyClD (TyClDecl name pat)
56 | InstD (InstDecl name pat)
57 | DefD (DefaultDecl name)
58 | ValD (HsBinds name pat)
59 | ForD (ForeignDecl name)
60 | FixD (FixitySig name)
61 | DeprecD (DeprecDecl name)
62 | RuleD (RuleDecl name pat)
64 -- NB: all top-level fixity decls are contained EITHER
66 -- OR in the ClassDecls in TyClDs
69 -- a) data constructors
70 -- b) class methods (but they can be also done in the
71 -- signatures of class decls)
72 -- c) imported functions (that have an IfacSig)
75 -- The latter is for class methods only
80 hsDeclName :: (NamedThing name, Outputable name, Outputable pat)
81 => HsDecl name pat -> name
83 hsDeclName (TyClD decl) = tyClDeclName decl
84 hsDeclName (InstD decl) = instDeclName decl
85 hsDeclName (ForD (ForeignDecl name _ _ _ _ _)) = name
86 hsDeclName (FixD (FixitySig name _ _)) = name
87 -- Others don't make sense
89 hsDeclName x = pprPanic "HsDecls.hsDeclName" (ppr x)
93 instDeclName :: InstDecl name pat -> name
94 instDeclName (InstDecl _ _ _ (Just name) _) = name
99 instance (NamedThing name, Outputable name, Outputable pat)
100 => Outputable (HsDecl name pat) where
102 ppr (TyClD dcl) = ppr dcl
103 ppr (ValD binds) = ppr binds
104 ppr (DefD def) = ppr def
105 ppr (InstD inst) = ppr inst
106 ppr (ForD fd) = ppr fd
107 ppr (FixD fd) = ppr fd
108 ppr (RuleD rd) = ppr rd
109 ppr (DeprecD dd) = ppr dd
113 %************************************************************************
115 \subsection[TyDecl]{@data@, @newtype@ or @type@ (synonym) type declaration}
117 %************************************************************************
119 Type and class declarations carry 'implicit names'. In particular:
123 Each data type decl defines
124 a worker name for each constructor
125 to-T and from-T convertors
126 Each class decl defines
127 a tycon for the class
128 a data constructor for that tycon
129 the worker for that constructor
130 a selector for each superclass
132 All have occurrence names that are derived uniquely from their parent declaration.
134 None of these get separate definitions in an interface file; they are
135 fully defined by the data or class decl. But they may *occur* in
136 interface files, of course. Any such occurrence must haul in the
137 relevant type or class decl.
140 - Make up their occurrence names immediately
142 - Ensure they "point to" the parent data/class decl
143 when loading that decl from an interface file
145 - When renaming the decl look them up in the name cache,
146 ensure correct module and provenance is set
148 Type B: Default methods and dictionary functions
149 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150 Have their own binding in an interface file.
152 Default methods : occurrence name is derived uniquely from the class decl.
153 Dict functions : occurrence name is derived from the instance decl, plus a unique number.
156 - Do *not* make them point to the parent class decl
157 - Interface-file decls: treat just like Type A
158 - Source-file decls: the names aren't in the decl at all;
159 instead the typechecker makes them up
162 data TyClDecl name pat
163 = IfaceSig { tcdName :: name, -- It may seem odd to classify an interface-file signature
164 tcdType :: HsType name, -- as a 'TyClDecl', but it's very convenient. These three
165 tcdIdInfo :: [HsIdInfo name], -- are the kind that appear in interface files.
169 | TyData { tcdND :: NewOrData,
170 tcdCtxt :: HsContext name, -- context
171 tcdName :: name, -- type constructor
172 tcdTyVars :: [HsTyVarBndr name], -- type variables
173 tcdCons :: [ConDecl name], -- data constructors (empty if abstract)
174 tcdNCons :: Int, -- Number of data constructors (valid even if type is abstract)
175 tcdDerivs :: Maybe [name], -- derivings; Nothing => not specified
176 -- (i.e., derive default); Just [] => derive
177 -- *nothing*; Just <list> => as you would
179 tcdSysNames :: DataSysNames name, -- Generic converter functions
183 | TySynonym { tcdName :: name, -- type constructor
184 tcdTyVars :: [HsTyVarBndr name], -- type variables
185 tcdSynRhs :: HsType name, -- synonym expansion
189 | ClassDecl { tcdCtxt :: HsContext name, -- Context...
190 tcdName :: name, -- Name of the class
191 tcdTyVars :: [HsTyVarBndr name], -- The class type variables
192 tcdFDs :: [FunDep name], -- Functional dependencies
193 tcdSigs :: [Sig name], -- Methods' signatures
194 tcdMeths :: Maybe (MonoBinds name pat), -- Default methods
195 -- Nothing for imported class decls
196 -- Just bs for source class decls
197 tcdSysNames :: ClassSysNames name,
205 isIfaceSigDecl, isDataDecl, isSynDecl, isClassDecl :: TyClDecl name pat -> Bool
207 isIfaceSigDecl (IfaceSig {}) = True
208 isIfaceSigDecl other = False
210 isSynDecl (TySynonym {}) = True
211 isSynDecl other = False
213 isDataDecl (TyData {}) = True
214 isDataDecl other = False
216 isClassDecl (ClassDecl {}) = True
217 isClassDecl other = False
223 --------------------------------
224 tyClDeclName :: TyClDecl name pat -> name
225 tyClDeclName tycl_decl = tcdName tycl_decl
227 --------------------------------
228 tyClDeclNames :: Eq name => TyClDecl name pat -> [(name, SrcLoc)]
229 -- Returns all the *binding* names of the decl, along with their SrcLocs
230 -- The first one is guaranteed to be the name of the decl
231 -- For record fields, the first one counts as the SrcLoc
232 -- We use the equality to filter out duplicate field names
234 tyClDeclNames (TySynonym {tcdName = name, tcdLoc = loc}) = [(name,loc)]
235 tyClDeclNames (IfaceSig {tcdName = name, tcdLoc = loc}) = [(name,loc)]
237 tyClDeclNames (ClassDecl {tcdName = cls_name, tcdSigs = sigs, tcdLoc = loc})
238 = (cls_name,loc) : [(n,loc) | ClassOpSig n _ _ loc <- sigs]
240 tyClDeclNames (TyData {tcdName = tc_name, tcdCons = cons, tcdLoc = loc})
241 = (tc_name,loc) : conDeclsNames cons
244 --------------------------------
245 -- The "system names" are extra implicit names *bound* by the decl.
246 -- They are kept in a list rather than a tuple
247 -- to make the renamer easier.
249 type ClassSysNames name = [name]
250 -- For class decls they are:
251 -- [tycon, datacon wrapper, datacon worker,
252 -- superclass selector 1, ..., superclass selector n]
254 type DataSysNames name = [name]
255 -- For data decls they are
257 -- where from :: T -> Tring
260 tyClDeclSysNames :: TyClDecl name pat -> [(name, SrcLoc)]
261 -- Similar to tyClDeclNames, but returns the "implicit"
262 -- or "system" names of the declaration
264 tyClDeclSysNames (ClassDecl {tcdSysNames = names, tcdLoc = loc, tcdSigs = sigs})
265 = [(n,loc) | n <- names]
266 tyClDeclSysNames (TyData {tcdCons = cons, tcdSysNames = names, tcdLoc = loc})
267 = [(n,loc) | n <- names] ++
268 [(wkr_name,loc) | ConDecl _ wkr_name _ _ _ loc <- cons]
269 tyClDeclSysNames decl = []
272 mkClassDeclSysNames :: (name, name, name, [name]) -> [name]
273 getClassDeclSysNames :: [name] -> (name, name, name, [name])
274 mkClassDeclSysNames (a,b,c,ds) = a:b:c:ds
275 getClassDeclSysNames (a:b:c:ds) = (a,b,c,ds)
279 instance (NamedThing name, Ord name) => Eq (TyClDecl name pat) where
280 -- Used only when building interface files
281 (==) d1@(IfaceSig {}) d2@(IfaceSig {})
282 = tcdName d1 == tcdName d2 &&
283 tcdType d1 == tcdType d2 &&
284 tcdIdInfo d1 == tcdIdInfo d2
286 (==) d1@(TyData {}) d2@(TyData {})
287 = tcdName d1 == tcdName d2 &&
288 tcdND d1 == tcdND d2 &&
289 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
290 eq_hsContext env (tcdCtxt d1) (tcdCtxt d2) &&
291 eqListBy (eq_ConDecl env) (tcdCons d1) (tcdCons d2)
294 (==) d1@(TySynonym {}) d2@(TySynonym {})
295 = tcdName d1 == tcdName d2 &&
296 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
297 eq_hsType env (tcdSynRhs d1) (tcdSynRhs d2)
300 (==) d1@(ClassDecl {}) d2@(ClassDecl {})
301 = tcdName d1 == tcdName d2 &&
302 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
303 eq_hsContext env (tcdCtxt d1) (tcdCtxt d2) &&
304 eqListBy (eq_hsFD env) (tcdFDs d1) (tcdFDs d2) &&
305 eqListBy (eq_cls_sig env) (tcdSigs d1) (tcdSigs d2)
308 (==) _ _ = False -- default case
310 eq_hsFD env (ns1,ms1) (ns2,ms2)
311 = eqListBy (eq_hsVar env) ns1 ns2 && eqListBy (eq_hsVar env) ms1 ms2
313 eq_cls_sig env (ClassOpSig n1 dm1 ty1 _) (ClassOpSig n2 dm2 ty2 _)
314 = n1==n2 && dm1 `eq_dm` dm2 && eq_hsType env ty1 ty2
316 -- Ignore the name of the default method for (DefMeth id)
317 -- This is used for comparing declarations before putting
318 -- them into interface files, and the name of the default
319 -- method isn't relevant
320 NoDefMeth `eq_dm` NoDefMeth = True
321 GenDefMeth `eq_dm` GenDefMeth = True
322 DefMeth _ `eq_dm` DefMeth _ = True
323 dm1 `eq_dm` dm2 = False
329 countTyClDecls :: [TyClDecl name pat] -> (Int, Int, Int, Int, Int)
330 -- class, data, newtype, synonym decls
332 = (length [() | ClassDecl {} <- decls],
333 length [() | TySynonym {} <- decls],
334 length [() | IfaceSig {} <- decls],
335 length [() | TyData {tcdND = DataType} <- decls],
336 length [() | TyData {tcdND = NewType} <- decls])
340 instance (NamedThing name, Outputable name, Outputable pat)
341 => Outputable (TyClDecl name pat) where
343 ppr (IfaceSig {tcdName = var, tcdType = ty, tcdIdInfo = info})
344 = hsep [ppr var, dcolon, ppr ty, pprHsIdInfo info]
346 ppr (TySynonym {tcdName = tycon, tcdTyVars = tyvars, tcdSynRhs = mono_ty})
347 = hang (ptext SLIT("type") <+> pp_decl_head [] tycon tyvars <+> equals)
350 ppr (TyData {tcdND = new_or_data, tcdCtxt = context, tcdName = tycon,
351 tcdTyVars = tyvars, tcdCons = condecls, tcdNCons = ncons,
352 tcdDerivs = derivings})
353 = pp_tydecl (ptext keyword <+> pp_decl_head context tycon tyvars <+> equals)
354 (pp_condecls condecls ncons)
357 keyword = case new_or_data of
358 NewType -> SLIT("newtype")
359 DataType -> SLIT("data")
361 ppr (ClassDecl {tcdCtxt = context, tcdName = clas, tcdTyVars = tyvars, tcdFDs = fds,
362 tcdSigs = sigs, tcdMeths = methods})
363 | null sigs -- No "where" part
366 | otherwise -- Laid out
367 = sep [hsep [top_matter, ptext SLIT("where {")],
368 nest 4 (sep [sep (map ppr_sig sigs), pp_methods, char '}'])]
370 top_matter = ptext SLIT("class") <+> pp_decl_head context clas tyvars <+> pprFundeps fds
371 ppr_sig sig = ppr sig <> semi
372 pp_methods = getPprStyle $ \ sty ->
373 if ifaceStyle sty then empty else ppr methods
375 pp_decl_head :: Outputable name => HsContext name -> name -> [HsTyVarBndr name] -> SDoc
376 pp_decl_head context thing tyvars = hsep [pprHsContext context, ppr thing, interppSP tyvars]
378 pp_condecls [] ncons = ptext SLIT("{- abstract with") <+> int ncons <+> ptext SLIT("constructors -}")
379 pp_condecls (c:cs) ncons = sep (ppr c : map (\ c -> ptext SLIT("|") <+> ppr c) cs)
381 pp_tydecl pp_head pp_decl_rhs derivings
382 = hang pp_head 4 (sep [
386 Just ds -> hsep [ptext SLIT("deriving"), parens (interpp'SP ds)]
391 %************************************************************************
393 \subsection[ConDecl]{A data-constructor declaration}
395 %************************************************************************
399 = ConDecl name -- Constructor name; this is used for the
400 -- DataCon itself, and for the user-callable wrapper Id
402 name -- Name of the constructor's 'worker Id'
403 -- Filled in as the ConDecl is built
405 [HsTyVarBndr name] -- Existentially quantified type variables
406 (HsContext name) -- ...and context
407 -- If both are empty then there are no existentials
413 = VanillaCon -- prefix-style con decl
416 | InfixCon -- infix-style con decl
420 | RecCon -- record-style con decl
421 [([name], BangType name)] -- list of "fields"
425 conDeclsNames :: Eq name => [ConDecl name] -> [(name,SrcLoc)]
426 -- See tyClDeclNames for what this does
427 -- The function is boringly complicated because of the records
428 -- And since we only have equality, we have to be a little careful
430 = snd (foldl do_one ([], []) cons)
432 do_one (flds_seen, acc) (ConDecl name _ _ _ details loc)
433 = do_details ((name,loc):acc) details
435 do_details acc (RecCon flds) = foldl do_fld (flds_seen, acc) flds
436 do_details acc other = (flds_seen, acc)
438 do_fld acc (flds, _) = foldl do_fld1 acc flds
440 do_fld1 (flds_seen, acc) fld
441 | fld `elem` flds_seen = (flds_seen,acc)
442 | otherwise = (fld:flds_seen, (fld,loc):acc)
446 conDetailsTys :: ConDetails name -> [HsType name]
447 conDetailsTys (VanillaCon btys) = map getBangType btys
448 conDetailsTys (InfixCon bty1 bty2) = [getBangType bty1, getBangType bty2]
449 conDetailsTys (RecCon fields) = [getBangType bty | (_, bty) <- fields]
452 eq_ConDecl env (ConDecl n1 _ tvs1 cxt1 cds1 _)
453 (ConDecl n2 _ tvs2 cxt2 cds2 _)
455 (eq_hsTyVars env tvs1 tvs2 $ \ env ->
456 eq_hsContext env cxt1 cxt2 &&
457 eq_ConDetails env cds1 cds2)
459 eq_ConDetails env (VanillaCon bts1) (VanillaCon bts2)
460 = eqListBy (eq_btype env) bts1 bts2
461 eq_ConDetails env (InfixCon bta1 btb1) (InfixCon bta2 btb2)
462 = eq_btype env bta1 bta2 && eq_btype env btb1 btb2
463 eq_ConDetails env (RecCon fs1) (RecCon fs2)
464 = eqListBy (eq_fld env) fs1 fs2
465 eq_ConDetails env _ _ = False
467 eq_fld env (ns1,bt1) (ns2, bt2) = ns1==ns2 && eq_btype env bt1 bt2
472 = Banged (HsType name) -- HsType: to allow Haskell extensions
473 | Unbanged (HsType name) -- (MonoType only needed for straight Haskell)
474 | Unpacked (HsType name) -- Field is strict and to be unpacked if poss.
476 getBangType (Banged ty) = ty
477 getBangType (Unbanged ty) = ty
478 getBangType (Unpacked ty) = ty
480 eq_btype env (Banged t1) (Banged t2) = eq_hsType env t1 t2
481 eq_btype env (Unbanged t1) (Unbanged t2) = eq_hsType env t1 t2
482 eq_btype env (Unpacked t1) (Unpacked t2) = eq_hsType env t1 t2
483 eq_btype env _ _ = False
487 instance (Outputable name) => Outputable (ConDecl name) where
488 ppr (ConDecl con _ tvs cxt con_details loc)
489 = sep [pprHsForAll tvs cxt, ppr_con_details con con_details]
491 ppr_con_details con (InfixCon ty1 ty2)
492 = hsep [ppr_bang ty1, ppr con, ppr_bang ty2]
494 ppr_con_details con (VanillaCon tys)
495 = ppr con <+> hsep (map (ppr_bang) tys)
497 ppr_con_details con (RecCon fields)
498 = ppr con <+> braces (hsep (punctuate comma (map ppr_field fields)))
500 ppr_field (ns, ty) = hsep (map (ppr) ns) <+>
504 instance Outputable name => Outputable (BangType name) where
507 ppr_bang (Banged ty) = ptext SLIT("!") <> pprParendHsType ty
508 ppr_bang (Unbanged ty) = pprParendHsType ty
509 ppr_bang (Unpacked ty) = ptext SLIT("! !") <> pprParendHsType ty
513 %************************************************************************
515 \subsection[InstDecl]{An instance declaration
517 %************************************************************************
520 data InstDecl name pat
521 = InstDecl (HsType name) -- Context => Class Instance-type
522 -- Using a polytype means that the renamer conveniently
523 -- figures out the quantified type variables for us.
527 [Sig name] -- User-supplied pragmatic info
529 (Maybe name) -- Name for the dictionary function
530 -- Nothing for source-file instance decls
536 instance (Outputable name, Outputable pat)
537 => Outputable (InstDecl name pat) where
539 ppr (InstDecl inst_ty binds uprags maybe_dfun_name src_loc)
540 = getPprStyle $ \ sty ->
541 if ifaceStyle sty then
542 hsep [ptext SLIT("instance"), ppr inst_ty, equals, pp_dfun]
544 vcat [hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")],
548 pp_dfun = case maybe_dfun_name of
554 instance Ord name => Eq (InstDecl name pat) where
555 -- Used for interface comparison only, so don't compare bindings
556 (==) (InstDecl inst_ty1 _ _ dfun1 _) (InstDecl inst_ty2 _ _ dfun2 _)
557 = inst_ty1 == inst_ty2 && dfun1 == dfun2
561 %************************************************************************
563 \subsection[DefaultDecl]{A @default@ declaration}
565 %************************************************************************
567 There can only be one default declaration per module, but it is hard
568 for the parser to check that; we pass them all through in the abstract
569 syntax, and that restriction must be checked in the front end.
572 data DefaultDecl name
573 = DefaultDecl [HsType name]
576 instance (Outputable name)
577 => Outputable (DefaultDecl name) where
579 ppr (DefaultDecl tys src_loc)
580 = ptext SLIT("default") <+> parens (interpp'SP tys)
583 %************************************************************************
585 \subsection{Foreign function interface declaration}
587 %************************************************************************
590 data ForeignDecl name =
599 instance (Outputable name)
600 => Outputable (ForeignDecl name) where
602 ppr (ForeignDecl nm imp_exp ty ext_name cconv src_loc)
603 = ptext SLIT("foreign") <+> ppr_imp_exp <+> pprCallConv cconv <+>
604 ppr ext_name <+> ppr_unsafe <+> ppr nm <+> dcolon <+> ppr ty
606 (ppr_imp_exp, ppr_unsafe) =
608 FoLabel -> (ptext SLIT("label"), empty)
609 FoExport -> (ptext SLIT("export"), empty)
611 | us -> (ptext SLIT("import"), ptext SLIT("unsafe"))
612 | otherwise -> (ptext SLIT("import"), empty)
617 | FoImport Bool -- True => unsafe call.
621 | ExtName CLabelString -- The external name of the foreign thing,
622 (Maybe CLabelString) -- and optionally its DLL or module name
623 -- Both of these are completely unencoded;
624 -- we just print them as they are
626 isDynamicExtName :: ExtName -> Bool
627 isDynamicExtName Dynamic = True
628 isDynamicExtName _ = False
630 extNameStatic :: ExtName -> CLabelString
631 extNameStatic (ExtName f _) = f
632 extNameStatic Dynamic = panic "staticExtName: Dynamic - shouldn't ever happen."
634 instance Outputable ExtName where
635 ppr Dynamic = ptext SLIT("dynamic")
636 ppr (ExtName nm mb_mod) =
637 case mb_mod of { Nothing -> empty; Just m -> doubleQuotes (ptext m) } <+>
638 doubleQuotes (pprCLabelString nm)
641 %************************************************************************
643 \subsection{Transformation rules}
645 %************************************************************************
648 data RuleDecl name pat
649 = HsRule -- Source rule
650 FAST_STRING -- Rule name
651 [name] -- Forall'd tyvars, filled in by the renamer with
652 -- tyvars mentioned in sigs; then filled out by typechecker
653 [RuleBndr name] -- Forall'd term vars
654 (HsExpr name pat) -- LHS
655 (HsExpr name pat) -- RHS
658 | IfaceRule -- One that's come in from an interface file; pre-typecheck
660 [UfBinder name] -- Tyvars and term vars
662 [UfExpr name] -- Args of LHS
663 (UfExpr name) -- Pre typecheck
666 | IfaceRuleOut -- Post typecheck
670 isIfaceRuleDecl (HsRule _ _ _ _ _ _) = False
671 isIfaceRuleDecl other = True
673 ifaceRuleDeclName :: RuleDecl name pat -> name
674 ifaceRuleDeclName (IfaceRule _ _ n _ _ _) = n
675 ifaceRuleDeclName (IfaceRuleOut n r) = n
676 ifaceRuleDeclName (HsRule fs _ _ _ _ _) = pprPanic "ifaceRuleDeclName" (ppr fs)
680 | RuleBndrSig name (HsType name)
682 instance (NamedThing name, Ord name) => Eq (RuleDecl name pat) where
683 -- Works for IfaceRules only; used when comparing interface file versions
684 (IfaceRule n1 bs1 f1 es1 rhs1 _) == (IfaceRule n2 bs2 f2 es2 rhs2 _)
685 = n1==n2 && f1 == f2 &&
686 eq_ufBinders emptyEqHsEnv bs1 bs2 (\env ->
687 eqListBy (eq_ufExpr env) (rhs1:es1) (rhs2:es2))
689 instance (NamedThing name, Outputable name, Outputable pat)
690 => Outputable (RuleDecl name pat) where
691 ppr (HsRule name tvs ns lhs rhs loc)
692 = sep [text "{-# RULES" <+> doubleQuotes (ptext name),
693 pp_forall, ppr lhs, equals <+> ppr rhs,
696 pp_forall | null tvs && null ns = empty
697 | otherwise = text "forall" <+>
698 fsep (map ppr tvs ++ map ppr ns)
701 ppr (IfaceRule name tpl_vars fn tpl_args rhs loc)
702 = hsep [ doubleQuotes (ptext name),
703 ptext SLIT("__forall") <+> braces (interppSP tpl_vars),
704 ppr fn <+> sep (map (pprUfExpr parens) tpl_args),
705 ptext SLIT("=") <+> ppr rhs
708 ppr (IfaceRuleOut fn rule) = pprCoreRule (ppr fn) rule
710 instance Outputable name => Outputable (RuleBndr name) where
711 ppr (RuleBndr name) = ppr name
712 ppr (RuleBndrSig name ty) = ppr name <> dcolon <> ppr ty
716 %************************************************************************
718 \subsection[DeprecDecl]{Deprecations}
720 %************************************************************************
722 We use exported entities for things to deprecate.
725 data DeprecDecl name = Deprecation name DeprecTxt SrcLoc
727 type DeprecTxt = FAST_STRING -- reason/explanation for deprecation
729 instance Outputable name => Outputable (DeprecDecl name) where
730 ppr (Deprecation thing txt _)
731 = hsep [text "{-# DEPRECATED", ppr thing, doubleQuotes (ppr txt), text "#-}"]