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 Bool -- True => source imported module
33 -- (current interpretation: ignore ufolding info)
34 (Maybe Module) -- as Module
35 (Maybe (Bool, [IE name])) -- (True => hiding, names)
40 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
41 ppr sty (ImportDecl mod qual as_source as spec _)
42 = hang (hsep [ptext SLIT("import"), pp_src as_source,
43 pp_qual qual, ptext mod, pp_as as])
47 pp_src True = ptext SLIT("{-# SOURCE #-}")
50 pp_qual True = ptext SLIT("qualified")
53 pp_as (Just a) = (<>) (ptext SLIT("as ")) (ptext a)
55 pp_spec Nothing = empty
56 pp_spec (Just (False, spec))
57 = parens (interpp'SP sty spec)
58 pp_spec (Just (True, spec))
59 = (<>) (ptext SLIT("hiding ")) (parens (interpp'SP sty spec))
62 %************************************************************************
64 \subsection{Imported and exported entities}
66 %************************************************************************
71 | IEThingAbs name -- Class/Type (can't tell)
72 | IEThingAll name -- Class/Type plus all methods/constructors
73 | IEThingWith name [name] -- Class/Type plus some methods/constructors
74 | IEModuleContents Module -- (Export Only)
78 ieName :: IE name -> name
80 ieName (IEThingAbs n) = n
81 ieName (IEThingWith n _) = n
82 ieName (IEThingAll n) = n
86 instance (NamedThing name, Outputable name) => Outputable (IE name) where
87 ppr sty (IEVar var) = ppr sty var
88 ppr sty (IEThingAbs thing) = ppr sty thing
89 ppr sty (IEThingAll thing)
90 = hcat [ppr sty thing, text "(..)"]
91 ppr sty (IEThingWith thing withs)
92 = (<>) (ppr sty thing)
93 (parens (fsep (punctuate comma (map (ppr sty) withs))))
94 ppr sty (IEModuleContents mod)
95 = (<>) (ptext SLIT("module ")) (ptext mod)