[project @ 1998-01-12 14:44:37 by simonm]
[ghc-hetmet.git] / ghc / compiler / deSugar / Desugar.lhs
index 281d988..8bee5d6 100644 (file)
@@ -4,38 +4,32 @@
 \section[Desugar]{@deSugar@: the main function}
 
 \begin{code}
-#include "HsVersions.h"
-
-module Desugar ( deSugar, pprDsWarnings
-#if __GLASGOW_HASKELL__ < 200
-               , DsMatchContext
-               , DsWarnFlavour -- fluff needed for closure, 
-                                -- removed when compiling with 1.4
-#endif
-              ) where
+module Desugar ( deSugar, pprDsWarnings ) where
 
-IMP_Ubiq(){-uitous-}
+#include "HsVersions.h"
 
-import HsSyn           ( HsBinds, HsExpr, MonoBinds,
-                         SYN_IE(RecFlag), nonRecursive, recursive
+import CmdLineOpts     ( opt_D_dump_ds )
+import HsSyn           ( HsBinds, HsExpr, MonoBinds
                        )
-import TcHsSyn         ( SYN_IE(TypecheckedMonoBinds), SYN_IE(TypecheckedHsExpr)
+import TcHsSyn         ( TypecheckedMonoBinds, TypecheckedHsExpr
                        )
 import CoreSyn
+import PprCore         ( pprCoreBindings )
 import Name             ( isExported )
 import DsMonad
 import DsBinds         ( dsMonoBinds )
 import DsUtils
 
-import Bag             ( unionBags )
-import BasicTypes       ( SYN_IE(Module) )
+import Bag             ( unionBags, isEmptyBag )
+import BasicTypes       ( Module, RecFlag(..) )
 import CmdLineOpts     ( opt_DoCoreLinting, opt_SccGroup, opt_SccProfilingOn )
 import CostCentre       ( IsCafCC(..), mkAutoCC )
 import CoreLift                ( liftCoreBindings )
 import CoreLint                ( lintCoreBindings )
 import Id              ( nullIdEnv, mkIdEnv, idType, 
-                         SYN_IE(DictVar), GenId, SYN_IE(Id) )
-import Outputable      ( PprStyle(..) )
+                         DictVar, GenId, Id )
+import ErrUtils                ( dumpIfSet, doIfSet )
+import Outputable
 import UniqSupply      ( splitUniqSupply, UniqSupply )
 \end{code}
 
@@ -46,8 +40,7 @@ start.
 deSugar :: UniqSupply          -- name supply
        -> Module               -- module name
        -> TypecheckedMonoBinds
-       -> ([CoreBinding],      -- output
-           DsWarnings)     -- Shadowing complaints
+       -> IO [CoreBinding]     -- output
 
 deSugar us mod_name all_binds
   = let
@@ -58,14 +51,22 @@ deSugar us mod_name all_binds
                        Just xx -> _PK_ xx
                        Nothing -> mod_name     -- default: module name
 
-       (core_prs, shadows) = initDs us1 nullIdEnv module_and_group 
-                             (dsMonoBinds opt_SccProfilingOn recursive all_binds [])
-
-       lift_final_binds = liftCoreBindings us2 [Rec core_prs]
+       (core_prs, ds_warns) = initDs us1 nullIdEnv module_and_group 
+                              (dsMonoBinds opt_SccProfilingOn all_binds [])
 
-       really_final_binds = if opt_DoCoreLinting
-                            then lintCoreBindings PprDebug "Desugarer" False lift_final_binds
-                            else lift_final_binds
+       ds_binds = liftCoreBindings us2 [Rec core_prs]
     in
-    (really_final_binds, shadows)
+
+       -- Display any warnings
+    doIfSet (not (isEmptyBag ds_warns))
+       (printErrs (pprDsWarnings ds_warns)) >>
+
+       -- Lint result if necessary
+    lintCoreBindings "Desugarer" False ds_binds >>
+
+       -- Dump output
+    dumpIfSet opt_D_dump_ds "Desugared:"
+       (pprCoreBindings ds_binds)      >>
+
+    return ds_binds    
 \end{code}