%
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
\begin{code}
-#include "HsVersions.h"
-
module HsImpExp where
-IMP_Ubiq()
+#include "HsVersions.h"
-import Name ( pprNonSym )
+import OccName ( Module, pprModule, moduleIfaceFlavour, bootFlavour )
import Outputable
-import PprStyle ( PprStyle(..) )
-import Pretty
import SrcLoc ( SrcLoc )
\end{code}
\end{code}
\begin{code}
-instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
- ppr sty (ImportDecl mod qual as spec _)
- = ppHang (ppCat [ppPStr SLIT("import"), pp_qual qual, ppPStr mod, pp_as as])
+instance (Outputable name) => Outputable (ImportDecl name) where
+ ppr (ImportDecl mod qual as spec _)
+ = hang (hsep [ptext SLIT("import"), pp_src,
+ pp_qual qual, pprModule mod, pp_as as])
4 (pp_spec spec)
where
- pp_qual False = ppNil
- pp_qual True = ppPStr SLIT("qualified")
+ pp_src | bootFlavour (moduleIfaceFlavour mod) = ptext SLIT("{-# SOURCE #-}")
+ | otherwise = empty
+
+ pp_qual False = empty
+ pp_qual True = ptext SLIT("qualified")
- pp_as Nothing = ppNil
- pp_as (Just a) = ppBeside (ppPStr SLIT("as ")) (ppPStr a)
+ pp_as Nothing = empty
+ pp_as (Just a) = ptext SLIT("as ") <+> pprModule a
- pp_spec Nothing = ppNil
+ pp_spec Nothing = empty
pp_spec (Just (False, spec))
- = ppParens (interpp'SP sty spec)
+ = parens (interpp'SP spec)
pp_spec (Just (True, spec))
- = ppBeside (ppPStr SLIT("hiding ")) (ppParens (interpp'SP sty spec))
+ = ptext SLIT("hiding") <+> parens (interpp'SP spec)
\end{code}
%************************************************************************
\end{code}
\begin{code}
-instance (NamedThing name, Outputable name) => Outputable (IE name) where
- ppr sty (IEVar var) = pprNonSym sty var
- ppr sty (IEThingAbs thing) = ppr sty thing
- ppr sty (IEThingAll thing)
- = ppBesides [ppr sty thing, ppStr "(..)"]
- ppr sty (IEThingWith thing withs)
- = ppBeside (ppr sty thing)
- (ppParens (ppInterleave ppComma (map (pprNonSym sty) withs)))
- ppr sty (IEModuleContents mod)
- = ppBeside (ppPStr SLIT("module ")) (ppPStr mod)
+instance (Outputable name) => Outputable (IE name) where
+ ppr (IEVar var) = ppr var
+ ppr (IEThingAbs thing) = ppr thing
+ ppr (IEThingAll thing) = hcat [ppr thing, text "(..)"]
+ ppr (IEThingWith thing withs)
+ = ppr thing <> parens (fsep (punctuate comma (map ppr withs)))
+ ppr (IEModuleContents mod)
+ = ptext SLIT("module") <+> pprModule mod
\end{code}