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)
53 %************************************************************************
55 \subsection{Imported and exported entities}
57 %************************************************************************
62 | IEThingAbs name -- Class/Type (can't tell)
63 | IEThingAll name -- Class/Type plus all methods/constructors
64 | IEThingWith name [name] -- Class/Type plus some methods/constructors
65 | IEModuleContents ModuleName -- (Export Only)
69 ieName :: IE name -> name
71 ieName (IEThingAbs n) = n
72 ieName (IEThingWith n _) = n
73 ieName (IEThingAll n) = n
75 ieNames :: IE a -> [a]
76 ieNames (IEVar n ) = [n]
77 ieNames (IEThingAbs n ) = [n]
78 ieNames (IEThingAll n ) = [n]
79 ieNames (IEThingWith n ns) = n:ns
80 ieNames (IEModuleContents _ ) = []
84 instance (Outputable name) => Outputable (IE name) where
85 ppr (IEVar var) = ppr var
86 ppr (IEThingAbs thing) = ppr thing
87 ppr (IEThingAll thing) = hcat [ppr thing, text "(..)"]
88 ppr (IEThingWith thing withs)
89 = ppr thing <> parens (fsep (punctuate comma (map ppr withs)))
90 ppr (IEModuleContents mod)
91 = ptext SLIT("module") <+> ppr mod