2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
7 #include "HsVersions.h"
15 import SrcLoc ( SrcLoc )
16 #if __GLASGOW_HASKELL__ >= 202
21 %************************************************************************
23 \subsection{Import and export declaration lists}
25 %************************************************************************
27 One per \tr{import} declaration in a module.
30 = ImportDecl Module -- module name
31 Bool -- True => qualified
32 (Maybe Module) -- as Module
33 (Maybe (Bool, [IE name])) -- (True => hiding, names)
38 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
39 ppr sty (ImportDecl mod qual as spec _)
40 = hang (hsep [ptext SLIT("import"), pp_qual qual, ptext mod, pp_as as])
44 pp_qual True = ptext SLIT("qualified")
47 pp_as (Just a) = (<>) (ptext SLIT("as ")) (ptext a)
49 pp_spec Nothing = empty
50 pp_spec (Just (False, spec))
51 = parens (interpp'SP sty spec)
52 pp_spec (Just (True, spec))
53 = (<>) (ptext SLIT("hiding ")) (parens (interpp'SP sty spec))
56 %************************************************************************
58 \subsection{Imported and exported entities}
60 %************************************************************************
65 | IEThingAbs name -- Class/Type (can't tell)
66 | IEThingAll name -- Class/Type plus all methods/constructors
67 | IEThingWith name [name] -- Class/Type plus some methods/constructors
68 | IEModuleContents Module -- (Export Only)
72 ieName :: IE name -> name
74 ieName (IEThingAbs n) = n
75 ieName (IEThingWith n _) = n
76 ieName (IEThingAll n) = n
80 instance (NamedThing name, Outputable name) => Outputable (IE name) where
81 ppr sty (IEVar var) = ppr sty var
82 ppr sty (IEThingAbs thing) = ppr sty thing
83 ppr sty (IEThingAll thing)
84 = hcat [ppr sty thing, text "(..)"]
85 ppr sty (IEThingWith thing withs)
86 = (<>) (ppr sty thing)
87 (parens (fsep (punctuate comma (map (ppr sty) withs))))
88 ppr sty (IEModuleContents mod)
89 = (<>) (ptext SLIT("module ")) (ptext mod)