2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
9 #include "HsVersions.h"
11 import BasicTypes ( Module, IfaceFlavour(..) )
12 import Name ( NamedThing )
14 import SrcLoc ( SrcLoc )
17 %************************************************************************
19 \subsection{Import and export declaration lists}
21 %************************************************************************
23 One per \tr{import} declaration in a module.
26 = ImportDecl Module -- module name
27 Bool -- True => qualified
28 IfaceFlavour -- True => source imported module
29 -- (current interpretation: ignore ufolding info)
30 (Maybe Module) -- as Module
31 (Maybe (Bool, [IE name])) -- (True => hiding, names)
36 instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
37 ppr (ImportDecl mod qual as_source as spec _)
38 = hang (hsep [ptext SLIT("import"), pp_src as_source,
39 pp_qual qual, ptext mod, pp_as as])
43 pp_src HiBootFile = ptext SLIT("{-# SOURCE #-}")
46 pp_qual True = ptext SLIT("qualified")
49 pp_as (Just a) = ptext SLIT("as ") <+> ptext a
51 pp_spec Nothing = empty
52 pp_spec (Just (False, spec))
53 = parens (interpp'SP spec)
54 pp_spec (Just (True, spec))
55 = ptext SLIT("hiding") <+> parens (interpp'SP spec)
58 %************************************************************************
60 \subsection{Imported and exported entities}
62 %************************************************************************
67 | IEThingAbs name -- Class/Type (can't tell)
68 | IEThingAll name -- Class/Type plus all methods/constructors
69 | IEThingWith name [name] -- Class/Type plus some methods/constructors
70 | IEModuleContents Module -- (Export Only)
74 ieName :: IE name -> name
76 ieName (IEThingAbs n) = n
77 ieName (IEThingWith n _) = n
78 ieName (IEThingAll n) = n
82 instance (NamedThing name, Outputable name) => Outputable (IE name) where
83 ppr (IEVar var) = ppr var
84 ppr (IEThingAbs thing) = ppr thing
85 ppr (IEThingAll thing) = hcat [ppr thing, text "(..)"]
86 ppr (IEThingWith thing withs)
87 = ppr thing <> parens (fsep (punctuate comma (map ppr withs)))
88 ppr (IEModuleContents mod)
89 = ptext SLIT("module") <+> ptext mod