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