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 ( Module, pprModule, moduleIfaceFlavour, bootFlavour )
13 import SrcLoc ( SrcLoc )
16 %************************************************************************
18 \subsection{Import and export declaration lists}
20 %************************************************************************
22 One per \tr{import} declaration in a module.
25 = ImportDecl Module -- module name
26 Bool -- True => qualified
27 (Maybe Module) -- as Module
28 (Maybe (Bool, [IE name])) -- (True => hiding, names)
33 instance (Outputable name) => Outputable (ImportDecl name) where
34 ppr (ImportDecl mod qual as spec _)
35 = hang (hsep [ptext SLIT("import"), pp_src,
36 pp_qual qual, pprModule mod, pp_as as])
39 pp_src | bootFlavour (moduleIfaceFlavour mod) = ptext SLIT("{-# SOURCE #-}")
43 pp_qual True = ptext SLIT("qualified")
46 pp_as (Just a) = ptext SLIT("as ") <+> pprModule a
48 pp_spec Nothing = empty
49 pp_spec (Just (False, spec))
50 = parens (interpp'SP spec)
51 pp_spec (Just (True, spec))
52 = ptext SLIT("hiding") <+> parens (interpp'SP spec)
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 Module -- (Export Only)
71 ieName :: IE name -> name
73 ieName (IEThingAbs n) = n
74 ieName (IEThingWith n _) = n
75 ieName (IEThingAll n) = n
79 instance (Outputable name) => Outputable (IE name) where
80 ppr (IEVar var) = ppr var
81 ppr (IEThingAbs thing) = ppr thing
82 ppr (IEThingAll thing) = hcat [ppr thing, text "(..)"]
83 ppr (IEThingWith thing withs)
84 = ppr thing <> parens (fsep (punctuate comma (map ppr withs)))
85 ppr (IEModuleContents mod)
86 = ptext SLIT("module") <+> pprModule mod