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(..),
35 FixityDecl(..), Fixity(..), FixityDirection(..),
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.
68 data HsModule tyvar uvar name pat
71 (Maybe Version) -- source interface version number
72 (Maybe [IE name]) -- export list; Nothing => export everything
73 -- Just [] => export *nothing* (???)
74 -- Just [...] => as you would expect...
75 [ImportDecl name] -- We snaffle interesting stuff out of the
76 -- imported interfaces early on, adding that
77 -- info to TyDecls/etc; so this list is
78 -- often empty, downstream.
80 [HsDecl tyvar uvar name pat] -- Type, class, value, and interface signature decls
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
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"))
106 pp_nonnull [] = ppNil
107 pp_nonnull xs = ppAboves (map (ppr sty) xs)
109 pp_iface_version Nothing = ppNil
110 pp_iface_version (Just n) = ppCat [ppStr "{-# INTERFACE", ppInt n, ppStr "#-}"]