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