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 )
17 #if __GLASGOW_HASKELL__ >= 202
22 %************************************************************************
24 \subsection{Import and export declaration lists}
26 %************************************************************************
28 One per \tr{import} declaration in a module.
31 = ImportDecl Module -- module name
32 Bool -- True => qualified
33 (Maybe Module) -- as Module
34 (Maybe (Bool, [IE name])) -- (True => hiding, names)
39 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
40 ppr sty (ImportDecl mod qual as spec _)
41 = hang (hsep [ptext SLIT("import"), pp_qual qual, ptext mod, pp_as as])
45 pp_qual True = ptext SLIT("qualified")
48 pp_as (Just a) = (<>) (ptext SLIT("as ")) (ptext a)
50 pp_spec Nothing = empty
51 pp_spec (Just (False, spec))
52 = parens (interpp'SP sty spec)
53 pp_spec (Just (True, spec))
54 = (<>) (ptext SLIT("hiding ")) (parens (interpp'SP sty spec))
57 %************************************************************************
59 \subsection{Imported and exported entities}
61 %************************************************************************
66 | IEThingAbs name -- Class/Type (can't tell)
67 | IEThingAll name -- Class/Type plus all methods/constructors
68 | IEThingWith name [name] -- Class/Type plus some methods/constructors
69 | IEModuleContents Module -- (Export Only)
73 ieName :: IE name -> name
75 ieName (IEThingAbs n) = n
76 ieName (IEThingWith n _) = n
77 ieName (IEThingAll n) = n
81 instance (NamedThing name, Outputable name) => Outputable (IE name) where
82 ppr sty (IEVar var) = ppr sty var
83 ppr sty (IEThingAbs thing) = ppr sty thing
84 ppr sty (IEThingAll thing)
85 = hcat [ppr sty thing, text "(..)"]
86 ppr sty (IEThingWith thing withs)
87 = (<>) (ppr sty thing)
88 (parens (fsep (punctuate comma (map (ppr sty) withs))))
89 ppr sty (IEModuleContents mod)
90 = (<>) (ptext SLIT("module ")) (ptext mod)