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) ,
33 import HsDecls ( HsDecl(..), TyDecl(..), InstDecl(..), ClassDecl(..),
36 ConDecl(..), BangType(..),
37 IfaceSig(..), HsIdInfo, SpecDataSig(..), SpecInstSig(..),
46 import HsPragmas ( ClassPragmas, ClassOpPragmas,
47 DataPragmas, GenPragmas, InstancePragmas )
51 import FiniteMap ( FiniteMap )
52 import Outputable ( ifPprShowAll, ifnotPprForUser, interpp'SP, Outputable(..) )
54 import SrcLoc ( SrcLoc )
57 @Fake@ is a placeholder type; for when tyvars and uvars aren't used.
61 instance Outputable Fake
64 All we actually declare here is the top-level structure for a module.
66 data HsModule tyvar uvar name pat
69 (Maybe Version) -- source interface version number
70 (Maybe [IE name]) -- export list; Nothing => export everything
71 -- Just [] => export *nothing* (???)
72 -- Just [...] => as you would expect...
73 [ImportDecl name] -- We snaffle interesting stuff out of the
74 -- imported interfaces early on, adding that
75 -- info to TyDecls/etc; so this list is
76 -- often empty, downstream.
78 [HsDecl tyvar uvar name pat] -- Type, class, value, and interface signature decls
83 instance (NamedThing name, Outputable name, Outputable pat,
84 Eq tyvar, Outputable tyvar, Eq uvar, Outputable uvar)
85 => Outputable (HsModule tyvar uvar name pat) where
87 ppr sty (HsModule name iface_version exports imports fixities
90 ifPprShowAll sty (ppr sty src_loc),
91 ifnotPprForUser sty (pp_iface_version iface_version),
93 Nothing -> ppCat [ppPStr SLIT("module"), ppPStr name, ppPStr SLIT("where")]
95 ppCat [ppPStr SLIT("module"), ppPStr name, ppLparen],
96 ppNest 8 (interpp'SP sty es),
97 ppNest 4 (ppPStr SLIT(") where"))
104 pp_nonnull [] = ppNil
105 pp_nonnull xs = ppAboves (map (ppr sty) xs)
107 pp_iface_version Nothing = ppNil
108 pp_iface_version (Just n) = ppCat [ppStr "{-# INTERFACE", ppInt n, ppStr "#-}"]