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"
19 #if (! defined(REALLY_HASKELL_1_3)) || PATRICK_FIXES_MODULE_DOTDOT_THING
23 EXP_MODULE(HsImpExp) ,
25 EXP_MODULE(HsMatches) ,
62 collectMonoBindersAndLocs,
64 collectTopLevelBinders,
94 SYN_IE(ClassAssertion),
111 import HsPragmas ( ClassPragmas, ClassOpPragmas,
112 DataPragmas, GenPragmas, InstancePragmas )
114 import FiniteMap ( FiniteMap )
115 import Outputable ( ifPprShowAll, ifnotPprForUser, interpp'SP, Outputable(..) )
117 import SrcLoc ( SrcLoc )
120 @Fake@ is a placeholder type; for when tyvars and uvars aren't used.
124 instance Outputable Fake
127 All we actually declare here is the top-level structure for a module.
131 data HsModule tyvar uvar name pat
133 Module -- module name
134 (Maybe Version) -- source interface version number
135 (Maybe [IE name]) -- export list; Nothing => export everything
136 -- Just [] => export *nothing* (???)
137 -- Just [...] => as you would expect...
138 [ImportDecl name] -- We snaffle interesting stuff out of the
139 -- imported interfaces early on, adding that
140 -- info to TyDecls/etc; so this list is
141 -- often empty, downstream.
144 [SpecDataSig name] -- user pragmas that modify TyDecls
145 [ClassDecl tyvar uvar name pat]
146 [InstDecl tyvar uvar name pat]
147 [SpecInstSig name] -- user pragmas that modify InstDecls
149 (HsBinds tyvar uvar name pat) -- the main stuff, includes source sigs
150 [Sig name] -- interface sigs
155 instance (NamedThing name, Outputable name, Outputable pat,
156 Eq tyvar, Outputable tyvar, Eq uvar, Outputable uvar)
157 => Outputable (HsModule tyvar uvar name pat) where
159 ppr sty (HsModule name iface_version exports imports fixities
160 typedecls typesigs classdecls instdecls instsigs
161 defdecls binds sigs src_loc)
163 ifPprShowAll sty (ppr sty src_loc),
164 ifnotPprForUser sty (pp_iface_version iface_version),
166 Nothing -> ppCat [ppPStr SLIT("module"), ppPStr name, ppPStr SLIT("where")]
167 Just es -> ppAboves [
168 ppCat [ppPStr SLIT("module"), ppPStr name, ppLparen],
169 ppNest 8 (interpp'SP sty es),
170 ppNest 4 (ppPStr SLIT(") where"))
174 pp_nonnull typedecls,
176 pp_nonnull classdecls,
177 pp_nonnull instdecls,
184 pp_nonnull [] = ppNil
185 pp_nonnull xs = ppAboves (map (ppr sty) xs)
187 pp_iface_version Nothing = ppNil
188 pp_iface_version (Just n) = ppCat [ppStr "{-# INTERFACE", ppInt n, ppStr "#-}"]