[project @ 1997-07-05 03:02:04 by sof]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsImpExp.lhs
index 7bdf830..2e24797 100644 (file)
@@ -10,11 +10,13 @@ module HsImpExp where
 
 IMP_Ubiq()
 
-import Name            ( pprNonSym )
+import BasicTypes      ( IfaceFlavour(..) )
 import Outputable
-import PprStyle                ( PprStyle(..) )
 import Pretty
 import SrcLoc          ( SrcLoc )
+#if __GLASGOW_HASKELL__ >= 202
+import Name
+#endif
 \end{code}
 
 %************************************************************************
@@ -28,6 +30,8 @@ One per \tr{import} declaration in a module.
 data ImportDecl name
   = ImportDecl   Module                        -- module name
                  Bool                          -- True => qualified
+                 IfaceFlavour                  -- True => source imported module 
+                                               --    (current interpretation: ignore ufolding info)
                  (Maybe Module)                -- as Module
                  (Maybe (Bool, [IE name]))     -- (True => hiding, names)
                  SrcLoc
@@ -35,21 +39,25 @@ data ImportDecl name
 
 \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])
+    ppr sty (ImportDecl mod qual as_source as spec _)
+      = hang (hsep [ptext SLIT("import"), pp_src as_source, 
+                    pp_qual qual, ptext mod, pp_as as])
             4 (pp_spec spec)
       where
-       pp_qual False   = ppNil
-       pp_qual True    = ppPStr SLIT("qualified")
+       pp_src HiFile     = empty
+       pp_src HiBootFile = ptext SLIT("{-# SOURCE #-}")
 
-       pp_as Nothing   = ppNil
-       pp_as (Just a)  = ppBeside (ppPStr SLIT("as ")) (ppPStr a)
+       pp_qual False   = empty
+       pp_qual True    = ptext SLIT("qualified")
 
-       pp_spec Nothing = ppNil
+       pp_as Nothing   = empty
+       pp_as (Just a)  = (<>) (ptext SLIT("as ")) (ptext a)
+
+       pp_spec Nothing = empty
        pp_spec (Just (False, spec))
-                       = ppParens (interpp'SP sty spec)
+                       = parens (interpp'SP sty spec)
        pp_spec (Just (True, spec))
-                       = ppBeside (ppPStr SLIT("hiding ")) (ppParens (interpp'SP sty spec))
+                       = (<>) (ptext SLIT("hiding ")) (parens (interpp'SP sty spec))
 \end{code}
 
 %************************************************************************
@@ -57,6 +65,7 @@ instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) wher
 \subsection{Imported and exported entities}
 %*                                                                     *
 %************************************************************************
+
 \begin{code}
 data IE name
   = IEVar              name
@@ -67,14 +76,23 @@ data IE name
 \end{code}
 
 \begin{code}
+ieName :: IE name -> name
+ieName (IEVar n)        = n
+ieName (IEThingAbs  n)   = n
+ieName (IEThingWith n _) = n
+ieName (IEThingAll  n)   = n
+\end{code}
+
+\begin{code}
 instance (NamedThing name, Outputable name) => Outputable (IE name) where
-    ppr sty (IEVar     var)    = pprNonSym sty var
+    ppr sty (IEVar     var)    = ppr sty var
     ppr sty (IEThingAbs        thing)  = ppr sty thing
     ppr sty (IEThingAll        thing)
-       = ppBesides [ppr sty thing, ppStr "(..)"]
+       = hcat [ppr sty thing, text "(..)"]
     ppr sty (IEThingWith thing withs)
-       = ppBeside (ppr sty thing)
-           (ppParens (ppInterleave ppComma (map (pprNonSym sty) withs)))
+       = (<>) (ppr sty thing)
+           (parens (fsep (punctuate comma (map (ppr sty) withs))))
     ppr sty (IEModuleContents mod)
-       = ppBeside (ppPStr SLIT("module ")) (ppPStr mod)
+       = (<>) (ptext SLIT("module ")) (ptext mod)
 \end{code}
+