[project @ 2000-05-25 12:41:14 by simonpj]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsDecls.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[HsDecls]{Abstract syntax: global declarations}
5
6 Definitions for: @TyDecl@ and @ConDecl@, @ClassDecl@,
7 @InstDecl@, @DefaultDecl@ and @ForeignDecl@.
8
9 \begin{code}
10 module HsDecls (
11         HsDecl(..), TyClDecl(..), InstDecl(..), RuleDecl(..), RuleBndr(..),
12         DefaultDecl(..), ForeignDecl(..), ForKind(..),
13         ExtName(..), isDynamicExtName, extNameStatic,
14         ConDecl(..), ConDetails(..), BangType(..),
15         IfaceSig(..),  SpecDataSig(..), 
16         DeprecDecl(..), DeprecTxt,
17         hsDeclName, tyClDeclName, isClassDecl, isSynDecl, isDataDecl, countTyClDecls, toHsRule
18     ) where
19
20 #include "HsVersions.h"
21
22 -- friends:
23 import HsBinds          ( HsBinds, MonoBinds, Sig(..), FixitySig(..), nullMonoBinds )
24 import HsExpr           ( HsExpr )
25 import HsPragmas        ( DataPragmas, ClassPragmas )
26 import HsImpExp         ( IE(..) )
27 import HsTypes
28 import PprCore          ( pprCoreRule )
29 import HsCore           ( UfExpr(UfVar), UfBinder, IfaceSig(..), eq_ufBinders, eq_ufExpr, pprUfExpr, toUfExpr, toUfBndr )
30 import CoreSyn          ( CoreRule(..) )
31 import BasicTypes       ( Fixity, NewOrData(..) )
32 import CallConv         ( CallConv, pprCallConv )
33 import Var              ( TyVar, Id )
34 import Name             ( toRdrName )
35
36 -- others:
37 import PprType
38 import FunDeps          ( pprFundeps )
39 import Class            ( FunDep )
40 import CStrings         ( CLabelString, pprCLabelString )
41 import Outputable       
42 import SrcLoc           ( SrcLoc, noSrcLoc )
43 import Util
44 \end{code}
45
46
47 %************************************************************************
48 %*                                                                      *
49 \subsection[HsDecl]{Declarations}
50 %*                                                                      *
51 %************************************************************************
52
53 \begin{code}
54 data HsDecl name pat
55   = TyClD       (TyClDecl name pat)
56   | InstD       (InstDecl  name pat)
57   | DefD        (DefaultDecl name)
58   | ValD        (HsBinds name pat)
59   | ForD        (ForeignDecl name)
60   | SigD        (IfaceSig name)
61   | FixD        (FixitySig name)
62   | DeprecD     (DeprecDecl name)
63   | RuleD       (RuleDecl name pat)
64
65 -- NB: all top-level fixity decls are contained EITHER
66 -- EITHER FixDs
67 -- OR     in the ClassDecls in TyClDs
68 --
69 -- The former covers
70 --      a) data constructors
71 --      b) class methods (but they can be also done in the
72 --              signatures of class decls)
73 --      c) imported functions (that have an IfacSig)
74 --      d) top level decls
75 --
76 -- The latter is for class methods only
77 \end{code}
78
79 \begin{code}
80 #ifdef DEBUG
81 hsDeclName :: (Outputable name, Outputable pat)
82            => HsDecl name pat -> name
83 #endif
84 hsDeclName (TyClD decl)                           = tyClDeclName decl
85 hsDeclName (SigD    (IfaceSig name _ _ _))        = name
86 hsDeclName (InstD   (InstDecl _ _ _ name _))      = name
87 hsDeclName (ForD    (ForeignDecl name _ _ _ _ _)) = name
88 hsDeclName (FixD    (FixitySig name _ _))         = name
89 -- Others don't make sense
90 #ifdef DEBUG
91 hsDeclName x                                  = pprPanic "HsDecls.hsDeclName" (ppr x)
92 #endif
93
94 tyClDeclName :: TyClDecl name pat -> name
95 tyClDeclName (TyData _ _ name _ _ _ _ _ _)          = name
96 tyClDeclName (TySynonym name _ _ _)                 = name
97 tyClDeclName (ClassDecl _ name _ _ _ _ _ _ _ _ _ _) = name
98 \end{code}
99
100 \begin{code}
101 instance (Outputable name, Outputable pat)
102         => Outputable (HsDecl name pat) where
103
104     ppr (TyClD dcl)  = ppr dcl
105     ppr (SigD sig)   = ppr sig
106     ppr (ValD binds) = ppr binds
107     ppr (DefD def)   = ppr def
108     ppr (InstD inst) = ppr inst
109     ppr (ForD fd)    = ppr fd
110     ppr (FixD fd)    = ppr fd
111     ppr (RuleD rd)   = ppr rd
112     ppr (DeprecD dd) = ppr dd
113 \end{code}
114
115 \begin{code}
116 instance Ord name => Eq (HsDecl name pat) where
117         -- Used only when comparing interfaces, 
118         -- at which time only signature and type/class decls
119    (SigD s1)  == (SigD s2) = s1 == s2
120    (TyClD d1) == (TyClD d2) = d1 == d2
121 \end{code}
122
123
124 %************************************************************************
125 %*                                                                      *
126 \subsection[TyDecl]{@data@, @newtype@ or @type@ (synonym) type declaration}
127 %*                                                                      *
128 %************************************************************************
129
130 \begin{code}
131 data TyClDecl name pat
132   = TyData      NewOrData
133                 (HsContext name) -- context
134                 name             -- type constructor
135                 [HsTyVarBndr name]       -- type variables
136                 [ConDecl name]   -- data constructors (empty if abstract)
137                 Int              -- Number of data constructors (valid even if type is abstract)
138                 (Maybe [name])   -- derivings; Nothing => not specified
139                                  -- (i.e., derive default); Just [] => derive
140                                  -- *nothing*; Just <list> => as you would
141                                  -- expect...
142                 (DataPragmas name)
143                 SrcLoc
144
145   | TySynonym   name            -- type constructor
146                 [HsTyVarBndr name]      -- type variables
147                 (HsType name)   -- synonym expansion
148                 SrcLoc
149
150   | ClassDecl   (HsContext name)        -- context...
151                 name                    -- name of the class
152                 [HsTyVarBndr name]      -- the class type variables
153                 [FunDep name]           -- functional dependencies
154                 [Sig name]              -- methods' signatures
155                 (MonoBinds name pat)    -- default methods
156                 (ClassPragmas name)
157                 name name name [name]   -- The names of the tycon, datacon wrapper, datacon worker,
158                                         -- and superclass selectors for this class.
159                                         -- These are filled in as the ClassDecl is made.
160                 SrcLoc
161
162 instance Ord name => Eq (TyClDecl name pat) where
163         -- Used only when building interface files
164   (==) (TyData nd1 cxt1 n1 tvs1 cons1 _ _ _ _)
165        (TyData nd2 cxt2 n2 tvs2 cons2 _ _ _ _)
166     = n1 == n2 &&
167       nd1 == nd2 &&
168       eqWithHsTyVars tvs1 tvs2 (\ env -> 
169           eq_hsContext env cxt1 cxt2 &&
170           eqListBy (eq_ConDecl env) cons1 cons2
171       )
172
173   (==) (TySynonym n1 tvs1 ty1 _)
174        (TySynonym n2 tvs2 ty2 _)
175     =  n1 == n2 &&
176        eqWithHsTyVars tvs1 tvs2 (\ env -> eq_hsType env ty1 ty2)
177
178   (==) (ClassDecl cxt1 n1 tvs1 fds1 sigs1 _ _ _ _ _ _ _)
179        (ClassDecl cxt2 n2 tvs2 fds2 sigs2 _ _ _ _ _ _ _)
180     =  n1 == n2 &&
181        eqWithHsTyVars tvs1 tvs2 (\ env -> 
182           eq_hsContext env cxt1 cxt2 &&
183           eqListBy (eq_hsFD env) fds1 fds2 &&
184           eqListBy (eq_cls_sig env) sigs1 sigs2
185        )
186
187 eq_hsFD env (ns1,ms1) (ns2,ms2)
188   = eqListBy (eq_hsVar env) ns1 ns2 && eqListBy (eq_hsVar env) ms1 ms2
189
190 eq_cls_sig env (ClassOpSig n1 _ b1 ty1 _) (ClassOpSig n2 _ b2 ty2 _)
191   = n1==n2 && b1==b2 && eq_hsType env ty1 ty2
192 \end{code}
193
194 \begin{code}
195 countTyClDecls :: [TyClDecl name pat] -> (Int, Int, Int, Int)
196         -- class, data, newtype, synonym decls
197 countTyClDecls decls 
198  = (length [() | ClassDecl _ _ _ _ _ _ _ _ _ _ _ _ <- decls],
199     length [() | TyData DataType _ _ _ _ _ _ _ _   <- decls],
200     length [() | TyData NewType  _ _ _ _ _ _ _ _   <- decls],
201     length [() | TySynonym _ _ _ _                 <- decls])
202
203 isDataDecl, isSynDecl, isClassDecl :: TyClDecl name pat -> Bool
204
205 isSynDecl (TySynonym _ _ _ _) = True
206 isSynDecl other               = False
207
208 isDataDecl (TyData _ _ _ _ _ _ _ _ _) = True
209 isDataDecl other                      = False
210
211 isClassDecl (ClassDecl _ _ _ _ _ _ _ _ _ _ _ _) = True
212 isClassDecl other                               = False
213 \end{code}
214
215 \begin{code}
216 instance (Outputable name, Outputable pat)
217               => Outputable (TyClDecl name pat) where
218
219     ppr (TySynonym tycon tyvars mono_ty src_loc)
220       = hang (ptext SLIT("type") <+> pp_decl_head [] tycon tyvars <+> equals)
221              4 (ppr mono_ty)
222
223     ppr (TyData new_or_data context tycon tyvars condecls ncons derivings pragmas src_loc)
224       = pp_tydecl
225                   (ptext keyword <+> pp_decl_head context tycon tyvars <+> equals)
226                   (pp_condecls condecls ncons)
227                   derivings
228       where
229         keyword = case new_or_data of
230                         NewType  -> SLIT("newtype")
231                         DataType -> SLIT("data")
232
233     ppr (ClassDecl context clas tyvars fds sigs methods pragmas _ _ _ _ src_loc)
234       | null sigs       -- No "where" part
235       = top_matter
236
237       | otherwise       -- Laid out
238       = sep [hsep [top_matter, ptext SLIT("where {")],
239              nest 4 (sep [sep (map ppr_sig sigs), pp_methods, char '}'])]
240       where
241         top_matter  = ptext SLIT("class") <+> pp_decl_head context clas tyvars <+> pprFundeps fds
242         ppr_sig sig = ppr sig <> semi
243         pp_methods = getPprStyle $ \ sty ->
244                      if ifaceStyle sty then empty else ppr methods
245         
246
247 pp_decl_head :: Outputable name => HsContext name -> name -> [HsTyVarBndr name] -> SDoc
248 pp_decl_head context thing tyvars = hsep [pprHsContext context, ppr thing, interppSP tyvars]
249
250 pp_condecls []     ncons = ptext SLIT("{- abstract with") <+> int ncons <+> ptext SLIT("constructors -}")
251 pp_condecls (c:cs) ncons = sep (ppr c : map (\ c -> ptext SLIT("|") <+> ppr c) cs)
252
253 pp_tydecl pp_head pp_decl_rhs derivings
254   = hang pp_head 4 (sep [
255         pp_decl_rhs,
256         case derivings of
257           Nothing          -> empty
258           Just ds          -> hsep [ptext SLIT("deriving"), parens (interpp'SP ds)]
259     ])
260 \end{code}
261
262 A type for recording what types a datatype should be specialised to.
263 It's called a ``Sig'' because it's sort of like a ``type signature''
264 for an datatype declaration.
265
266 \begin{code}
267 data SpecDataSig name
268   = SpecDataSig name            -- tycon to specialise
269                 (HsType name)
270                 SrcLoc
271
272 instance (Outputable name)
273               => Outputable (SpecDataSig name) where
274
275     ppr (SpecDataSig tycon ty _)
276       = hsep [text "{-# SPECIALIZE data", ppr ty, text "#-}"]
277 \end{code}
278
279 %************************************************************************
280 %*                                                                      *
281 \subsection[ConDecl]{A data-constructor declaration}
282 %*                                                                      *
283 %************************************************************************
284
285 \begin{code}
286 data ConDecl name
287   = ConDecl     name                    -- Constructor name; this is used for the
288                                         -- DataCon itself, and for the user-callable wrapper Id
289
290                 name                    -- Name of the constructor's 'worker Id'
291                                         -- Filled in as the ConDecl is built
292
293                 [HsTyVarBndr name]              -- Existentially quantified type variables
294                 (HsContext name)        -- ...and context
295                                         -- If both are empty then there are no existentials
296
297                 (ConDetails name)
298                 SrcLoc
299
300 data ConDetails name
301   = VanillaCon                  -- prefix-style con decl
302                 [BangType name]
303
304   | InfixCon                    -- infix-style con decl
305                 (BangType name)
306                 (BangType name)
307
308   | RecCon                      -- record-style con decl
309                 [([name], BangType name)]       -- list of "fields"
310
311   | NewCon                      -- newtype con decl, possibly with a labelled field.
312                 (HsType name)
313                 (Maybe name)    -- Just x => labelled field 'x'
314
315 data BangType name
316   = Banged   (HsType name)      -- HsType: to allow Haskell extensions
317   | Unbanged (HsType name)      -- (MonoType only needed for straight Haskell)
318   | Unpacked (HsType name)      -- Field is strict and to be unpacked if poss.
319
320
321 eq_ConDecl env (ConDecl n1 _ tvs1 cxt1 cds1 _)
322                (ConDecl n2 _ tvs2 cxt2 cds2 _)
323   = n1 == n2 &&
324     (eqWithHsTyVars tvs1 tvs2   $ \ env ->
325      eq_hsContext env cxt1 cxt2 &&
326      eq_ConDetails env cds1 cds2)
327
328 eq_ConDetails env (VanillaCon bts1) (VanillaCon bts2)
329   = eqListBy (eq_btype env) bts1 bts2
330 eq_ConDetails env (InfixCon bta1 btb1) (InfixCon bta2 btb2)
331   = eq_btype env bta1 bta2 && eq_btype env btb1 btb2
332 eq_ConDetails env (RecCon fs1) (RecCon fs2)
333   = eqListBy (eq_fld env) fs1 fs2
334 eq_ConDetails env (NewCon t1 mn1) (NewCon t2 mn2)
335   = eq_hsType env t1 t2 && mn1 == mn2
336 eq_ConDetails env _ _ = False
337
338 eq_fld env (ns1,bt1) (ns2, bt2) = ns1==ns2 && eq_btype env bt1 bt2
339
340 eq_btype env (Banged t1)   (Banged t2)   = eq_hsType env t1 t2
341 eq_btype env (Unbanged t1) (Unbanged t2) = eq_hsType env t1 t2
342 eq_btype env (Unpacked t1) (Unpacked t2) = eq_hsType env t1 t2
343 \end{code}
344
345 \begin{code}
346 instance (Outputable name) => Outputable (ConDecl name) where
347     ppr (ConDecl con _ tvs cxt con_details  loc)
348       = sep [pprHsForAll tvs cxt, ppr_con_details con con_details]
349
350 ppr_con_details con (InfixCon ty1 ty2)
351   = hsep [ppr_bang ty1, ppr con, ppr_bang ty2]
352
353 ppr_con_details con (VanillaCon tys)
354   = ppr con <+> hsep (map (ppr_bang) tys)
355
356 ppr_con_details con (NewCon ty Nothing)
357   = ppr con <+> pprParendHsType ty
358
359 ppr_con_details con (NewCon ty (Just x))
360   = ppr con <+> braces pp_field 
361    where
362     pp_field = ppr x <+> dcolon <+> pprParendHsType ty
363  
364 ppr_con_details con (RecCon fields)
365   = ppr con <+> braces (hsep (punctuate comma (map ppr_field fields)))
366   where
367     ppr_field (ns, ty) = hsep (map (ppr) ns) <+> 
368                          dcolon <+>
369                          ppr_bang ty
370
371 instance Outputable name => Outputable (BangType name) where
372     ppr = ppr_bang
373
374 ppr_bang (Banged   ty) = ptext SLIT("!") <> pprParendHsType ty
375 ppr_bang (Unbanged ty) = pprParendHsType ty
376 ppr_bang (Unpacked ty) = ptext SLIT("! !") <> pprParendHsType ty
377 \end{code}
378
379
380 %************************************************************************
381 %*                                                                      *
382 \subsection[InstDecl]{An instance declaration
383 %*                                                                      *
384 %************************************************************************
385
386 \begin{code}
387 data InstDecl name pat
388   = InstDecl    (HsType name)   -- Context => Class Instance-type
389                                 -- Using a polytype means that the renamer conveniently
390                                 -- figures out the quantified type variables for us.
391
392                 (MonoBinds name pat)
393
394                 [Sig name]              -- User-supplied pragmatic info
395
396                 name                    -- Name for the dictionary function
397
398                 SrcLoc
399 \end{code}
400
401 \begin{code}
402 instance (Outputable name, Outputable pat)
403               => Outputable (InstDecl name pat) where
404
405     ppr (InstDecl inst_ty binds uprags dfun_name src_loc)
406       = getPprStyle $ \ sty ->
407         if ifaceStyle sty then
408            hsep [ptext SLIT("instance"), ppr inst_ty, equals, ppr dfun_name]
409         else
410            vcat [hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")],
411                  nest 4 (ppr uprags),
412                  nest 4 (ppr binds) ]
413 \end{code}
414
415 \begin{code}
416 instance Ord name => Eq (InstDecl name pat) where
417         -- Used for interface comparison only, so don't compare bindings
418   (==) (InstDecl inst_ty1 _ _ dfun1 _) (InstDecl inst_ty2 _ _ dfun2 _)
419        = inst_ty1 == inst_ty2 && dfun1 == dfun2
420 \end{code}
421
422
423 %************************************************************************
424 %*                                                                      *
425 \subsection[DefaultDecl]{A @default@ declaration}
426 %*                                                                      *
427 %************************************************************************
428
429 There can only be one default declaration per module, but it is hard
430 for the parser to check that; we pass them all through in the abstract
431 syntax, and that restriction must be checked in the front end.
432
433 \begin{code}
434 data DefaultDecl name
435   = DefaultDecl [HsType name]
436                 SrcLoc
437
438 instance (Outputable name)
439               => Outputable (DefaultDecl name) where
440
441     ppr (DefaultDecl tys src_loc)
442       = ptext SLIT("default") <+> parens (interpp'SP tys)
443 \end{code}
444
445 %************************************************************************
446 %*                                                                      *
447 \subsection{Foreign function interface declaration}
448 %*                                                                      *
449 %************************************************************************
450
451 \begin{code}
452 data ForeignDecl name = 
453    ForeignDecl 
454         name 
455         ForKind   
456         (HsType name)
457         ExtName
458         CallConv
459         SrcLoc
460
461 instance (Outputable name)
462               => Outputable (ForeignDecl name) where
463
464     ppr (ForeignDecl nm imp_exp ty ext_name cconv src_loc)
465       = ptext SLIT("foreign") <+> ppr_imp_exp <+> pprCallConv cconv <+> 
466         ppr ext_name <+> ppr_unsafe <+> ppr nm <+> dcolon <+> ppr ty
467         where
468          (ppr_imp_exp, ppr_unsafe) =
469            case imp_exp of
470              FoLabel     -> (ptext SLIT("label"), empty)
471              FoExport    -> (ptext SLIT("export"), empty)
472              FoImport us 
473                 | us        -> (ptext SLIT("import"), ptext SLIT("unsafe"))
474                 | otherwise -> (ptext SLIT("import"), empty)
475
476 data ForKind
477  = FoLabel
478  | FoExport
479  | FoImport Bool -- True  => unsafe call.
480
481 data ExtName
482  = Dynamic 
483  | ExtName CLabelString         -- The external name of the foreign thing,
484            (Maybe CLabelString) -- and optionally its DLL or module name
485                                 -- Both of these are completely unencoded; 
486                                 -- we just print them as they are
487
488 isDynamicExtName :: ExtName -> Bool
489 isDynamicExtName Dynamic = True
490 isDynamicExtName _       = False
491
492 extNameStatic :: ExtName -> CLabelString
493 extNameStatic (ExtName f _) = f
494 extNameStatic Dynamic       = panic "staticExtName: Dynamic - shouldn't ever happen."
495
496 instance Outputable ExtName where
497   ppr Dynamic      = ptext SLIT("dynamic")
498   ppr (ExtName nm mb_mod) = 
499      case mb_mod of { Nothing -> empty; Just m -> doubleQuotes (ptext m) } <+> 
500      doubleQuotes (pprCLabelString nm)
501 \end{code}
502
503 %************************************************************************
504 %*                                                                      *
505 \subsection{Transformation rules}
506 %*                                                                      *
507 %************************************************************************
508
509 \begin{code}
510 data RuleDecl name pat
511   = HsRule                      -- Source rule
512         FAST_STRING             -- Rule name
513         [name]                  -- Forall'd tyvars, filled in by the renamer with
514                                 -- tyvars mentioned in sigs; then filled out by typechecker
515         [RuleBndr name]         -- Forall'd term vars
516         (HsExpr name pat)       -- LHS
517         (HsExpr name pat)       -- RHS
518         SrcLoc          
519
520   | IfaceRule                   -- One that's come in from an interface file; pre-typecheck
521         FAST_STRING
522         [UfBinder name]         -- Tyvars and term vars
523         name                    -- Head of lhs
524         [UfExpr name]           -- Args of LHS
525         (UfExpr name)           -- Pre typecheck
526         SrcLoc          
527
528   | IfaceRuleOut                -- Post typecheck
529         name                    -- Head of LHS
530         CoreRule
531
532
533 data RuleBndr name
534   = RuleBndr name
535   | RuleBndrSig name (HsType name)
536
537 instance Ord name => Eq (RuleDecl name pat) where
538   -- Works for IfaceRules only; used when comparing interface file versions
539   (IfaceRule n1 bs1 f1 es1 rhs1 _) == (IfaceRule n2 bs2 f2 es2 rhs2 _)
540      = n1==n2 && f1 == f2 && 
541        eq_ufBinders emptyEqHsEnv bs1 bs2 (\env -> 
542        eqListBy (eq_ufExpr env) (rhs1:es1) (rhs2:es2))
543
544 instance (Outputable name, Outputable pat)
545               => Outputable (RuleDecl name pat) where
546   ppr (HsRule name tvs ns lhs rhs loc)
547         = sep [text "{-# RULES" <+> doubleQuotes (ptext name),
548                pp_forall, ppr lhs, equals <+> ppr rhs,
549                text "#-}" ]
550         where
551           pp_forall | null tvs && null ns = empty
552                     | otherwise           = text "forall" <+> 
553                                             fsep (map ppr tvs ++ map ppr ns)
554                                             <> dot
555
556   ppr (IfaceRule name tpl_vars fn tpl_args rhs loc) 
557     = hsep [ doubleQuotes (ptext name),
558            ptext SLIT("__forall") <+> braces (interppSP tpl_vars),
559            ppr fn <+> sep (map (pprUfExpr parens) tpl_args),
560            ptext SLIT("=") <+> ppr rhs
561       ] <+> semi
562
563   ppr (IfaceRuleOut fn rule) = pprCoreRule (ppr fn) rule
564
565 instance Outputable name => Outputable (RuleBndr name) where
566    ppr (RuleBndr name) = ppr name
567    ppr (RuleBndrSig name ty) = ppr name <> dcolon <> ppr ty
568
569 toHsRule id (BuiltinRule _)
570   = pprTrace "toHsRule: builtin" (ppr id) (bogusIfaceRule id)
571
572 toHsRule id (Rule name bndrs args rhs)
573   = IfaceRule name (map toUfBndr bndrs) (toRdrName id)
574               (map toUfExpr args) (toUfExpr rhs) noSrcLoc
575
576 bogusIfaceRule id
577   = IfaceRule SLIT("bogus") [] (toRdrName id) [] (UfVar (toRdrName id)) noSrcLoc
578 \end{code}
579
580
581 %************************************************************************
582 %*                                                                      *
583 \subsection[DeprecDecl]{Deprecations}
584 %*                                                                      *
585 %************************************************************************
586
587 We use exported entities for things to deprecate. Cunning trick (hack?):
588 `IEModuleContents undefined' is used for module deprecation.
589
590 \begin{code}
591 data DeprecDecl name = Deprecation (IE name) DeprecTxt SrcLoc
592
593 type DeprecTxt = FAST_STRING    -- reason/explanation for deprecation
594
595 instance Outputable name => Outputable (DeprecDecl name) where
596    ppr (Deprecation (IEModuleContents _) txt _)
597       = hsep [text "{-# DEPRECATED",            doubleQuotes (ppr txt), text "#-}"]
598    ppr (Deprecation thing txt _)
599       = hsep [text "{-# DEPRECATED", ppr thing, doubleQuotes (ppr txt), text "#-}"]
600 \end{code}