2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
7 #include "HsVersions.h"
13 import BasicTypes ( IfaceFlavour(..) )
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 IfaceFlavour -- True => source imported module
34 -- (current interpretation: ignore ufolding info)
35 (Maybe Module) -- as Module
36 (Maybe (Bool, [IE name])) -- (True => hiding, names)
41 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
42 ppr sty (ImportDecl mod qual as_source as spec _)
43 = hang (hsep [ptext SLIT("import"), pp_src as_source,
44 pp_qual qual, ptext mod, pp_as as])
48 pp_src HiBootFile = ptext SLIT("{-# SOURCE #-}")
51 pp_qual True = ptext SLIT("qualified")
54 pp_as (Just a) = (<>) (ptext SLIT("as ")) (ptext a)
56 pp_spec Nothing = empty
57 pp_spec (Just (False, spec))
58 = parens (interpp'SP sty spec)
59 pp_spec (Just (True, spec))
60 = (<>) (ptext SLIT("hiding ")) (parens (interpp'SP sty spec))
63 %************************************************************************
65 \subsection{Imported and exported entities}
67 %************************************************************************
72 | IEThingAbs name -- Class/Type (can't tell)
73 | IEThingAll name -- Class/Type plus all methods/constructors
74 | IEThingWith name [name] -- Class/Type plus some methods/constructors
75 | IEModuleContents Module -- (Export Only)
79 ieName :: IE name -> name
81 ieName (IEThingAbs n) = n
82 ieName (IEThingWith n _) = n
83 ieName (IEThingAll n) = n
87 instance (NamedThing name, Outputable name) => Outputable (IE name) where
88 ppr sty (IEVar var) = ppr sty var
89 ppr sty (IEThingAbs thing) = ppr sty thing
90 ppr sty (IEThingAll thing)
91 = hcat [ppr sty thing, text "(..)"]
92 ppr sty (IEThingWith thing withs)
93 = (<>) (ppr sty thing)
94 (parens (fsep (punctuate comma (map (ppr sty) withs))))
95 ppr sty (IEModuleContents mod)
96 = (<>) (ptext SLIT("module ")) (ptext mod)