2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section{Haskell abstract syntax definition}
6 This module glues together the pieces of the Haskell abstract syntax,
7 which is declared in the various \tr{Hs*} modules. This module,
8 therefore, is almost nothing but re-exporting.
11 #include "HsVersions.h"
15 -- NB: don't reexport HsCore or HsPragmas;
16 -- this module tells about "real Haskell"
41 import HsPragmas ( ClassPragmas, ClassOpPragmas,
42 DataPragmas, GenPragmas, InstancePragmas
45 import FiniteMap ( FiniteMap )
46 import Outputable ( ifPprShowAll, interpp'SP, Outputable(..){-instances-} )
48 import SrcLoc ( SrcLoc{-instances-} )
51 @Fake@ is a placeholder type; for when tyvars and uvars aren't used.
55 instance Outputable Fake
58 All we actually declare here is the top-level structure for a module.
60 data HsModule tyvar uvar name pat
62 FAST_STRING -- module name
63 (Maybe [IE name]) -- export list; Nothing => export everything
64 -- Just [] => export *nothing* (???)
65 -- Just [...] => as you would expect...
66 [ImportedInterface tyvar uvar name pat]
67 -- We snaffle interesting stuff out of the
68 -- imported interfaces early on, adding that
69 -- info to TyDecls/etc; so this list is
70 -- often empty, downstream.
73 [SpecDataSig name] -- user pragmas that modify TyDecls
74 [ClassDecl tyvar uvar name pat]
75 [InstDecl tyvar uvar name pat]
76 [SpecInstSig name] -- user pragmas that modify InstDecls
78 (HsBinds tyvar uvar name pat) -- the main stuff!
79 [Sig name] -- "Sigs" are folded into the "HsBinds"
80 -- pretty early on, so this list is
81 -- often either empty or just the
82 -- interface signatures.
87 instance (NamedThing name, Outputable name, Outputable pat,
88 Eq tyvar, Outputable tyvar, Eq uvar, Outputable uvar)
89 => Outputable (HsModule tyvar uvar name pat) where
91 ppr sty (HsModule name exports imports fixities
92 typedecls typesigs classdecls instdecls instsigs
93 defdecls binds sigs src_loc)
95 ifPprShowAll sty (ppr sty src_loc),
97 Nothing -> ppCat [ppPStr SLIT("module"), ppPStr name, ppPStr SLIT("where")]
99 ppCat [ppPStr SLIT("module"), ppPStr name, ppLparen],
100 ppNest 8 (interpp'SP sty es),
101 ppNest 4 (ppPStr SLIT(") where"))
103 pp_nonnull imports, pp_nonnull fixities,
104 pp_nonnull typedecls, pp_nonnull typesigs,
105 pp_nonnull classdecls,
106 pp_nonnull instdecls, pp_nonnull instsigs,
108 ppr sty binds, pp_nonnull sigs
111 pp_nonnull [] = ppNil
112 pp_nonnull xs = ppAboves (map (ppr sty) xs)