2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
7 #include "HsVersions.h"
13 import Name ( pprNonSym )
15 import PprStyle ( PprStyle(..) )
17 import SrcLoc ( SrcLoc )
20 %************************************************************************
22 \subsection{Import and export declaration lists}
24 %************************************************************************
26 One per \tr{import} declaration in a module.
29 = ImportDecl Module -- module name
30 Bool -- True => qualified
31 (Maybe Module) -- as Module
32 (Maybe (Bool, [IE name])) -- (True => hiding, names)
37 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
38 ppr sty (ImportDecl mod qual as spec _)
39 = ppHang (ppCat [ppPStr SLIT("import"), pp_qual qual, ppPStr mod, pp_as as])
43 pp_qual True = ppPStr SLIT("qualified")
46 pp_as (Just a) = ppBeside (ppPStr SLIT("as ")) (ppPStr a)
48 pp_spec Nothing = ppNil
49 pp_spec (Just (False, spec))
50 = ppParens (interpp'SP sty spec)
51 pp_spec (Just (True, spec))
52 = ppBeside (ppPStr SLIT("hiding ")) (ppParens (interpp'SP sty spec))
55 %************************************************************************
57 \subsection{Imported and exported entities}
59 %************************************************************************
63 | IEThingAbs name -- Class/Type (can't tell)
64 | IEThingAll name -- Class/Type plus all methods/constructors
65 | IEThingWith name [name] -- Class/Type plus some methods/constructors
66 | IEModuleContents Module -- (Export Only)
70 instance (NamedThing name, Outputable name) => Outputable (IE name) where
71 ppr sty (IEVar var) = pprNonSym sty var
72 ppr sty (IEThingAbs thing) = ppr sty thing
73 ppr sty (IEThingAll thing)
74 = ppBesides [ppr sty thing, ppStr "(..)"]
75 ppr sty (IEThingWith thing withs)
76 = ppBeside (ppr sty thing)
77 (ppParens (ppInterleave ppComma (map (pprNonSym sty) withs)))
78 ppr sty (IEModuleContents mod)
79 = ppBeside (ppPStr SLIT("module ")) (ppPStr mod)