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.
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 [(n,loc) | ClassOpSig _ (DefMeth n) _ loc <- sigs]
267 tyClDeclSysNames (TyData {tcdCons = cons, tcdSysNames = names, tcdLoc = loc})
268 = [(n,loc) | n <- names] ++
269 [(wkr_name,loc) | ConDecl _ wkr_name _ _ _ loc <- cons]
270 tyClDeclSysNames decl = []
273 mkClassDeclSysNames :: (name, name, name, [name]) -> [name]
274 getClassDeclSysNames :: [name] -> (name, name, name, [name])
275 mkClassDeclSysNames (a,b,c,ds) = a:b:c:ds
276 getClassDeclSysNames (a:b:c:ds) = (a,b,c,ds)
280 instance (NamedThing name, Ord name) => Eq (TyClDecl name pat) where
281 -- Used only when building interface files
282 (==) d1@(IfaceSig {}) d2@(IfaceSig {})
283 = tcdName d1 == tcdName d2 &&
284 tcdType d1 == tcdType d2 &&
285 tcdIdInfo d1 == tcdIdInfo d2
287 (==) d1@(TyData {}) d2@(TyData {})
288 = tcdName d1 == tcdName d2 &&
289 tcdND d1 == tcdND d2 &&
290 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
291 eq_hsContext env (tcdCtxt d1) (tcdCtxt d2) &&
292 eqListBy (eq_ConDecl env) (tcdCons d1) (tcdCons d2)
295 (==) d1@(TySynonym {}) d2@(TySynonym {})
296 = tcdName d1 == tcdName d2 &&
297 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
298 eq_hsType env (tcdSynRhs d1) (tcdSynRhs d2)
301 (==) d1@(ClassDecl {}) d2@(ClassDecl {})
302 = tcdName d1 == tcdName d2 &&
303 eqWithHsTyVars (tcdTyVars d1) (tcdTyVars d2) (\ env ->
304 eq_hsContext env (tcdCtxt d1) (tcdCtxt d2) &&
305 eqListBy (eq_hsFD env) (tcdFDs d1) (tcdFDs d2) &&
306 eqListBy (eq_cls_sig env) (tcdSigs d1) (tcdSigs d2)
309 (==) _ _ = False -- default case
311 eq_hsFD env (ns1,ms1) (ns2,ms2)
312 = eqListBy (eq_hsVar env) ns1 ns2 && eqListBy (eq_hsVar env) ms1 ms2
314 eq_cls_sig env (ClassOpSig n1 dm1 ty1 _) (ClassOpSig n2 dm2 ty2 _)
315 = n1==n2 && dm1 `eq_dm` dm2 && eq_hsType env ty1 ty2
317 -- Ignore the name of the default method for (DefMeth id)
318 -- This is used for comparing declarations before putting
319 -- them into interface files, and the name of the default
320 -- method isn't relevant
321 NoDefMeth `eq_dm` NoDefMeth = True
322 GenDefMeth `eq_dm` GenDefMeth = True
323 DefMeth _ `eq_dm` DefMeth _ = True
324 dm1 `eq_dm` dm2 = False
330 countTyClDecls :: [TyClDecl name pat] -> (Int, Int, Int, Int, Int)
331 -- class, data, newtype, synonym decls
333 = (length [() | ClassDecl {} <- decls],
334 length [() | TySynonym {} <- decls],
335 length [() | IfaceSig {} <- decls],
336 length [() | TyData {tcdND = DataType} <- decls],
337 length [() | TyData {tcdND = NewType} <- decls])
341 instance (NamedThing name, Outputable name, Outputable pat)
342 => Outputable (TyClDecl name pat) where
344 ppr (IfaceSig {tcdName = var, tcdType = ty, tcdIdInfo = info})
345 = hsep [ppr var, dcolon, ppr ty, pprHsIdInfo info]
347 ppr (TySynonym {tcdName = tycon, tcdTyVars = tyvars, tcdSynRhs = mono_ty})
348 = hang (ptext SLIT("type") <+> pp_decl_head [] tycon tyvars <+> equals)
351 ppr (TyData {tcdND = new_or_data, tcdCtxt = context, tcdName = tycon,
352 tcdTyVars = tyvars, tcdCons = condecls, tcdNCons = ncons,
353 tcdDerivs = derivings})
354 = pp_tydecl (ptext keyword <+> pp_decl_head context tycon tyvars <+> equals)
355 (pp_condecls condecls ncons)
358 keyword = case new_or_data of
359 NewType -> SLIT("newtype")
360 DataType -> SLIT("data")
362 ppr (ClassDecl {tcdCtxt = context, tcdName = clas, tcdTyVars = tyvars, tcdFDs = fds,
363 tcdSigs = sigs, tcdMeths = methods})
364 | null sigs -- No "where" part
367 | otherwise -- Laid out
368 = sep [hsep [top_matter, ptext SLIT("where {")],
369 nest 4 (sep [sep (map ppr_sig sigs), pp_methods, char '}'])]
371 top_matter = ptext SLIT("class") <+> pp_decl_head context clas tyvars <+> pprFundeps fds
372 ppr_sig sig = ppr sig <> semi
373 pp_methods = getPprStyle $ \ sty ->
374 if ifaceStyle sty then empty else ppr methods
376 pp_decl_head :: Outputable name => HsContext name -> name -> [HsTyVarBndr name] -> SDoc
377 pp_decl_head context thing tyvars = hsep [pprHsContext context, ppr thing, interppSP tyvars]
379 pp_condecls [] ncons = ptext SLIT("{- abstract with") <+> int ncons <+> ptext SLIT("constructors -}")
380 pp_condecls (c:cs) ncons = sep (ppr c : map (\ c -> ptext SLIT("|") <+> ppr c) cs)
382 pp_tydecl pp_head pp_decl_rhs derivings
383 = hang pp_head 4 (sep [
387 Just ds -> hsep [ptext SLIT("deriving"), parens (interpp'SP ds)]
392 %************************************************************************
394 \subsection[ConDecl]{A data-constructor declaration}
396 %************************************************************************
400 = ConDecl name -- Constructor name; this is used for the
401 -- DataCon itself, and for the user-callable wrapper Id
403 name -- Name of the constructor's 'worker Id'
404 -- Filled in as the ConDecl is built
406 [HsTyVarBndr name] -- Existentially quantified type variables
407 (HsContext name) -- ...and context
408 -- If both are empty then there are no existentials
414 = VanillaCon -- prefix-style con decl
417 | InfixCon -- infix-style con decl
421 | RecCon -- record-style con decl
422 [([name], BangType name)] -- list of "fields"
426 conDeclsNames :: Eq name => [ConDecl name] -> [(name,SrcLoc)]
427 -- See tyClDeclNames for what this does
428 -- The function is boringly complicated because of the records
429 -- And since we only have equality, we have to be a little careful
431 = snd (foldl do_one ([], []) cons)
433 do_one (flds_seen, acc) (ConDecl name _ _ _ details loc)
434 = do_details ((name,loc):acc) details
436 do_details acc (RecCon flds) = foldl do_fld (flds_seen, acc) flds
437 do_details acc other = (flds_seen, acc)
439 do_fld acc (flds, _) = foldl do_fld1 acc flds
441 do_fld1 (flds_seen, acc) fld
442 | fld `elem` flds_seen = (flds_seen,acc)
443 | otherwise = (fld:flds_seen, (fld,loc):acc)
447 conDetailsTys :: ConDetails name -> [HsType name]
448 conDetailsTys (VanillaCon btys) = map getBangType btys
449 conDetailsTys (InfixCon bty1 bty2) = [getBangType bty1, getBangType bty2]
450 conDetailsTys (RecCon fields) = [getBangType bty | (_, bty) <- fields]
453 eq_ConDecl env (ConDecl n1 _ tvs1 cxt1 cds1 _)
454 (ConDecl n2 _ tvs2 cxt2 cds2 _)
456 (eq_hsTyVars env tvs1 tvs2 $ \ env ->
457 eq_hsContext env cxt1 cxt2 &&
458 eq_ConDetails env cds1 cds2)
460 eq_ConDetails env (VanillaCon bts1) (VanillaCon bts2)
461 = eqListBy (eq_btype env) bts1 bts2
462 eq_ConDetails env (InfixCon bta1 btb1) (InfixCon bta2 btb2)
463 = eq_btype env bta1 bta2 && eq_btype env btb1 btb2
464 eq_ConDetails env (RecCon fs1) (RecCon fs2)
465 = eqListBy (eq_fld env) fs1 fs2
466 eq_ConDetails env _ _ = False
468 eq_fld env (ns1,bt1) (ns2, bt2) = ns1==ns2 && eq_btype env bt1 bt2
473 = Banged (HsType name) -- HsType: to allow Haskell extensions
474 | Unbanged (HsType name) -- (MonoType only needed for straight Haskell)
475 | Unpacked (HsType name) -- Field is strict and to be unpacked if poss.
477 getBangType (Banged ty) = ty
478 getBangType (Unbanged ty) = ty
479 getBangType (Unpacked ty) = ty
481 eq_btype env (Banged t1) (Banged t2) = eq_hsType env t1 t2
482 eq_btype env (Unbanged t1) (Unbanged t2) = eq_hsType env t1 t2
483 eq_btype env (Unpacked t1) (Unpacked t2) = eq_hsType env t1 t2
484 eq_btype env _ _ = False
488 instance (Outputable name) => Outputable (ConDecl name) where
489 ppr (ConDecl con _ tvs cxt con_details loc)
490 = sep [pprHsForAll tvs cxt, ppr_con_details con con_details]
492 ppr_con_details con (InfixCon ty1 ty2)
493 = hsep [ppr_bang ty1, ppr con, ppr_bang ty2]
495 ppr_con_details con (VanillaCon tys)
496 = ppr con <+> hsep (map (ppr_bang) tys)
498 ppr_con_details con (RecCon fields)
499 = ppr con <+> braces (hsep (punctuate comma (map ppr_field fields)))
501 ppr_field (ns, ty) = hsep (map (ppr) ns) <+>
505 instance Outputable name => Outputable (BangType name) where
508 ppr_bang (Banged ty) = ptext SLIT("!") <> pprParendHsType ty
509 ppr_bang (Unbanged ty) = pprParendHsType ty
510 ppr_bang (Unpacked ty) = ptext SLIT("! !") <> pprParendHsType ty
514 %************************************************************************
516 \subsection[InstDecl]{An instance declaration
518 %************************************************************************
521 data InstDecl name pat
522 = InstDecl (HsType name) -- Context => Class Instance-type
523 -- Using a polytype means that the renamer conveniently
524 -- figures out the quantified type variables for us.
528 [Sig name] -- User-supplied pragmatic info
530 (Maybe name) -- Name for the dictionary function
531 -- Nothing for source-file instance decls
537 instance (Outputable name, Outputable pat)
538 => Outputable (InstDecl name pat) where
540 ppr (InstDecl inst_ty binds uprags maybe_dfun_name src_loc)
541 = getPprStyle $ \ sty ->
542 if ifaceStyle sty then
543 hsep [ptext SLIT("instance"), ppr inst_ty, equals, pp_dfun]
545 vcat [hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")],
549 pp_dfun = case maybe_dfun_name of
555 instance Ord name => Eq (InstDecl name pat) where
556 -- Used for interface comparison only, so don't compare bindings
557 (==) (InstDecl inst_ty1 _ _ dfun1 _) (InstDecl inst_ty2 _ _ dfun2 _)
558 = inst_ty1 == inst_ty2 && dfun1 == dfun2
562 %************************************************************************
564 \subsection[DefaultDecl]{A @default@ declaration}
566 %************************************************************************
568 There can only be one default declaration per module, but it is hard
569 for the parser to check that; we pass them all through in the abstract
570 syntax, and that restriction must be checked in the front end.
573 data DefaultDecl name
574 = DefaultDecl [HsType name]
577 instance (Outputable name)
578 => Outputable (DefaultDecl name) where
580 ppr (DefaultDecl tys src_loc)
581 = ptext SLIT("default") <+> parens (interpp'SP tys)
584 %************************************************************************
586 \subsection{Foreign function interface declaration}
588 %************************************************************************
591 data ForeignDecl name =
600 instance (Outputable name)
601 => Outputable (ForeignDecl name) where
603 ppr (ForeignDecl nm imp_exp ty ext_name cconv src_loc)
604 = ptext SLIT("foreign") <+> ppr_imp_exp <+> pprCallConv cconv <+>
605 ppr ext_name <+> ppr_unsafe <+> ppr nm <+> dcolon <+> ppr ty
607 (ppr_imp_exp, ppr_unsafe) =
609 FoLabel -> (ptext SLIT("label"), empty)
610 FoExport -> (ptext SLIT("export"), empty)
612 | us -> (ptext SLIT("import"), ptext SLIT("unsafe"))
613 | otherwise -> (ptext SLIT("import"), empty)
618 | FoImport Bool -- True => unsafe call.
622 | ExtName CLabelString -- The external name of the foreign thing,
623 (Maybe CLabelString) -- and optionally its DLL or module name
624 -- Both of these are completely unencoded;
625 -- we just print them as they are
627 isDynamicExtName :: ExtName -> Bool
628 isDynamicExtName Dynamic = True
629 isDynamicExtName _ = False
631 extNameStatic :: ExtName -> CLabelString
632 extNameStatic (ExtName f _) = f
633 extNameStatic Dynamic = panic "staticExtName: Dynamic - shouldn't ever happen."
635 instance Outputable ExtName where
636 ppr Dynamic = ptext SLIT("dynamic")
637 ppr (ExtName nm mb_mod) =
638 case mb_mod of { Nothing -> empty; Just m -> doubleQuotes (ptext m) } <+>
639 doubleQuotes (pprCLabelString nm)
642 %************************************************************************
644 \subsection{Transformation rules}
646 %************************************************************************
649 data RuleDecl name pat
650 = HsRule -- Source rule
651 FAST_STRING -- Rule name
652 [name] -- Forall'd tyvars, filled in by the renamer with
653 -- tyvars mentioned in sigs; then filled out by typechecker
654 [RuleBndr name] -- Forall'd term vars
655 (HsExpr name pat) -- LHS
656 (HsExpr name pat) -- RHS
659 | IfaceRule -- One that's come in from an interface file; pre-typecheck
661 [UfBinder name] -- Tyvars and term vars
663 [UfExpr name] -- Args of LHS
664 (UfExpr name) -- Pre typecheck
667 | IfaceRuleOut -- Post typecheck
671 isIfaceRuleDecl (HsRule _ _ _ _ _ _) = False
672 isIfaceRuleDecl other = True
674 ifaceRuleDeclName :: RuleDecl name pat -> name
675 ifaceRuleDeclName (IfaceRule _ _ n _ _ _) = n
676 ifaceRuleDeclName (IfaceRuleOut n r) = n
677 ifaceRuleDeclName (HsRule fs _ _ _ _ _) = pprPanic "ifaceRuleDeclName" (ppr fs)
681 | RuleBndrSig name (HsType name)
683 instance (NamedThing name, Ord name) => Eq (RuleDecl name pat) where
684 -- Works for IfaceRules only; used when comparing interface file versions
685 (IfaceRule n1 bs1 f1 es1 rhs1 _) == (IfaceRule n2 bs2 f2 es2 rhs2 _)
686 = n1==n2 && f1 == f2 &&
687 eq_ufBinders emptyEqHsEnv bs1 bs2 (\env ->
688 eqListBy (eq_ufExpr env) (rhs1:es1) (rhs2:es2))
690 instance (NamedThing name, Outputable name, Outputable pat)
691 => Outputable (RuleDecl name pat) where
692 ppr (HsRule name tvs ns lhs rhs loc)
693 = sep [text "{-# RULES" <+> doubleQuotes (ptext name),
694 pp_forall, ppr lhs, equals <+> ppr rhs,
697 pp_forall | null tvs && null ns = empty
698 | otherwise = text "forall" <+>
699 fsep (map ppr tvs ++ map ppr ns)
702 ppr (IfaceRule name tpl_vars fn tpl_args rhs loc)
703 = hsep [ doubleQuotes (ptext name),
704 ptext SLIT("__forall") <+> braces (interppSP tpl_vars),
705 ppr fn <+> sep (map (pprUfExpr parens) tpl_args),
706 ptext SLIT("=") <+> ppr rhs
709 ppr (IfaceRuleOut fn rule) = pprCoreRule (ppr fn) rule
711 instance Outputable name => Outputable (RuleBndr name) where
712 ppr (RuleBndr name) = ppr name
713 ppr (RuleBndrSig name ty) = ppr name <> dcolon <> ppr ty
717 %************************************************************************
719 \subsection[DeprecDecl]{Deprecations}
721 %************************************************************************
723 We use exported entities for things to deprecate.
726 data DeprecDecl name = Deprecation name DeprecTxt SrcLoc
728 type DeprecTxt = FAST_STRING -- reason/explanation for deprecation
730 instance Outputable name => Outputable (DeprecDecl name) where
731 ppr (Deprecation thing txt _)
732 = hsep [text "{-# DEPRECATED", ppr thing, doubleQuotes (ppr txt), text "#-}"]