2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
7 #include "HsVersions.h"
14 import PprStyle ( PprStyle(..) )
16 import SrcLoc ( SrcLoc )
19 %************************************************************************
21 \subsection{Import and export declaration lists}
23 %************************************************************************
25 One per \tr{import} declaration in a module.
28 = ImportDecl Module -- module name
29 Bool -- True => qualified
30 (Maybe Module) -- as Module
31 (Maybe (Bool, [IE name])) -- (True => hiding, names)
36 instance (Outputable name) => Outputable (ImportDecl name) where
37 ppr sty (ImportDecl mod qual as spec _)
38 = ppHang (ppCat [ppStr "import", pp_qual qual, ppPStr mod, pp_as as])
42 pp_qual True = ppStr "qualified"
45 pp_as (Just a) = ppCat [ppStr "as", ppPStr a]
47 pp_spec Nothing = ppNil
48 pp_spec (Just (False, spec))
49 = ppBesides [ppStr "(", interpp'SP sty spec, ppStr ")"]
50 pp_spec (Just (True, spec))
51 = ppBesides [ppStr "hiding (", interpp'SP sty spec, ppStr ")"]
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 (Outputable name) => Outputable (IE name) where
71 ppr sty (IEVar var) = ppr 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 = ppBesides [ppr sty thing, ppLparen, ppInterleave ppComma (map (ppr sty) withs), ppRparen]
77 ppr sty (IEModuleContents mod)
78 = ppBeside (ppPStr SLIT("module ")) (ppPStr mod)