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"
22 EXP_MODULE(HsImpExp) ,
24 EXP_MODULE(HsMatches) ,
40 import HsPragmas ( ClassPragmas, ClassOpPragmas,
41 DataPragmas, GenPragmas, InstancePragmas )
43 import FiniteMap ( FiniteMap )
44 import Outputable ( ifPprShowAll, ifnotPprForUser, interpp'SP, Outputable(..) )
46 import SrcLoc ( SrcLoc )
49 @Fake@ is a placeholder type; for when tyvars and uvars aren't used.
53 instance Outputable Fake
56 All we actually declare here is the top-level structure for a module.
60 data HsModule tyvar uvar name pat
63 (Maybe Version) -- source interface version number
64 (Maybe [IE name]) -- export list; Nothing => export everything
65 -- Just [] => export *nothing* (???)
66 -- Just [...] => as you would expect...
67 [ImportDecl name] -- 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, includes source sigs
79 [Sig name] -- interface sigs
84 instance (NamedThing name, Outputable name, Outputable pat,
85 Eq tyvar, Outputable tyvar, Eq uvar, Outputable uvar)
86 => Outputable (HsModule tyvar uvar name pat) where
88 ppr sty (HsModule name iface_version exports imports fixities
89 typedecls typesigs classdecls instdecls instsigs
90 defdecls binds sigs src_loc)
92 ifPprShowAll sty (ppr sty src_loc),
93 ifnotPprForUser sty (pp_iface_version iface_version),
95 Nothing -> ppCat [ppPStr SLIT("module"), ppPStr name, ppPStr SLIT("where")]
97 ppCat [ppPStr SLIT("module"), ppPStr name, ppLparen],
98 ppNest 8 (interpp'SP sty es),
99 ppNest 4 (ppPStr SLIT(") where"))
103 pp_nonnull typedecls,
105 pp_nonnull classdecls,
106 pp_nonnull instdecls,
113 pp_nonnull [] = ppNil
114 pp_nonnull xs = ppAboves (map (ppr sty) xs)
116 pp_iface_version Nothing = ppNil
117 pp_iface_version (Just n) = ppCat [ppStr "{-# INTERFACE", ppInt n, ppStr "#-}"]