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 )
44 import FiniteMap ( FiniteMap )
45 import Outputable ( ifPprShowAll, ifnotPprForUser, interpp'SP, Outputable(..) )
47 import SrcLoc ( SrcLoc )
50 @Fake@ is a placeholder type; for when tyvars and uvars aren't used.
54 instance Outputable Fake
57 All we actually declare here is the top-level structure for a module.
61 data HsModule tyvar uvar name pat
64 (Maybe Version) -- source interface version number
65 (Maybe [IE name]) -- export list; Nothing => export everything
66 -- Just [] => export *nothing* (???)
67 -- Just [...] => as you would expect...
68 [ImportDecl name] -- We snaffle interesting stuff out of the
69 -- imported interfaces early on, adding that
70 -- info to TyDecls/etc; so this list is
71 -- often empty, downstream.
74 [SpecDataSig name] -- user pragmas that modify TyDecls
75 [ClassDecl tyvar uvar name pat]
76 [InstDecl tyvar uvar name pat]
77 [SpecInstSig name] -- user pragmas that modify InstDecls
79 (HsBinds tyvar uvar name pat) -- the main stuff, includes source sigs
80 [Sig name] -- interface sigs
85 instance (NamedThing name, Outputable name, Outputable pat,
86 Eq tyvar, Outputable tyvar, Eq uvar, Outputable uvar)
87 => Outputable (HsModule tyvar uvar name pat) where
89 ppr sty (HsModule name iface_version exports imports fixities
90 typedecls typesigs classdecls instdecls instsigs
91 defdecls binds sigs src_loc)
93 ifPprShowAll sty (ppr sty src_loc),
94 ifnotPprForUser sty (pp_iface_version iface_version),
96 Nothing -> ppCat [ppPStr SLIT("module"), ppPStr name, ppPStr SLIT("where")]
98 ppCat [ppPStr SLIT("module"), ppPStr name, ppLparen],
99 ppNest 8 (interpp'SP sty es),
100 ppNest 4 (ppPStr SLIT(") where"))
104 pp_nonnull typedecls,
106 pp_nonnull classdecls,
107 pp_nonnull instdecls,
114 pp_nonnull [] = ppNil
115 pp_nonnull xs = ppAboves (map (ppr sty) xs)
117 pp_iface_version Nothing = ppNil
118 pp_iface_version (Just n) = ppCat [ppStr "{-# INTERFACE", ppInt n, ppStr "#-}"]