2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
9 #include "HsVersions.h"
11 import Module ( ModuleName, WhereFrom )
13 import SrcLoc ( SrcLoc )
16 %************************************************************************
18 \subsection{Import and export declaration lists}
20 %************************************************************************
22 One per \tr{import} declaration in a module.
25 = ImportDecl ModuleName -- module name
27 Bool -- True => qualified
28 (Maybe ModuleName) -- as Module
29 (Maybe (Bool, [IE name])) -- (True => hiding, names)
34 instance (Outputable name) => Outputable (ImportDecl name) where
35 ppr (ImportDecl mod from qual as spec _)
36 = hang (hsep [ptext SLIT("import"), ppr from,
37 pp_qual qual, ppr mod, pp_as as])
41 pp_qual True = ptext SLIT("qualified")
44 pp_as (Just a) = ptext SLIT("as ") <+> ppr a
46 pp_spec Nothing = empty
47 pp_spec (Just (False, spec))
48 = parens (interpp'SP spec)
49 pp_spec (Just (True, spec))
50 = ptext SLIT("hiding") <+> parens (interpp'SP spec)
52 ideclName (ImportDecl mod_nm _ _ _ _ _) = mod_nm
55 %************************************************************************
57 \subsection{Imported and exported entities}
59 %************************************************************************
64 | IEThingAbs name -- Class/Type (can't tell)
65 | IEThingAll name -- Class/Type plus all methods/constructors
66 | IEThingWith name [name] -- Class/Type plus some methods/constructors
67 | IEModuleContents ModuleName -- (Export Only)
71 ieName :: IE name -> name
73 ieName (IEThingAbs n) = n
74 ieName (IEThingWith n _) = n
75 ieName (IEThingAll n) = n
77 ieNames :: IE a -> [a]
78 ieNames (IEVar n ) = [n]
79 ieNames (IEThingAbs n ) = [n]
80 ieNames (IEThingAll n ) = [n]
81 ieNames (IEThingWith n ns) = n:ns
82 ieNames (IEModuleContents _ ) = []
86 instance (Outputable name) => Outputable (IE name) where
87 ppr (IEVar var) = ppr var
88 ppr (IEThingAbs thing) = ppr thing
89 ppr (IEThingAll thing) = hcat [ppr thing, text "(..)"]
90 ppr (IEThingWith thing withs)
91 = ppr thing <> parens (fsep (punctuate comma (map ppr withs)))
92 ppr (IEModuleContents mod)
93 = ptext SLIT("module") <+> ppr mod