Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modules
[ghc-hetmet.git] / compiler / deSugar / DsMonad.lhs
index 9251a81..4af6f68 100644 (file)
@@ -6,6 +6,13 @@
 @DsMonad@: monadery used in desugaring
 
 \begin{code}
+{-# OPTIONS_GHC -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+-- for details
+
 module DsMonad (
        DsM, mappM, mapAndUnzipM,
        initDs, initDsTc, returnDs, thenDs, listDs, fixDs, mapAndUnzipDs, 
@@ -20,10 +27,10 @@ module DsMonad (
        UniqSupply, newUniqueSupply,
        getDOptsDs, getGhcModeDs, doptDs,
        dsLookupGlobal, dsLookupGlobalId, dsLookupTyCon, dsLookupDataCon,
+        dsLookupClass,
 
        DsMetaEnv, DsMetaVal(..), dsLookupMetaEnv, dsExtendMetaEnv,
 
-        bindLocalsDs, getLocalBindsDs, getBkptSitesDs, getModNameRefDs, withModNameRefDs,
        -- Warnings
        DsWarning, warnDs, failWithDs,
 
@@ -44,6 +51,7 @@ import HscTypes
 import Bag
 import DataCon
 import TyCon
+import Class
 import Id
 import Module
 import Var
@@ -56,9 +64,6 @@ import NameEnv
 import OccName
 import DynFlags
 import ErrUtils
-import Bag
-import Breakpoints
-import OccName
 
 import Data.IORef
 
@@ -136,17 +141,13 @@ data DsGblEnv = DsGblEnv {
        ds_mod     :: Module,                   -- For SCC profiling
        ds_unqual  :: PrintUnqualified,
        ds_msgs    :: IORef Messages,           -- Warning messages
-       ds_if_env  :: (IfGblEnv, IfLclEnv),     -- Used for looking up global, 
+       ds_if_env  :: (IfGblEnv, IfLclEnv)      -- Used for looking up global, 
                                                -- possibly-imported things
-        ds_bkptSites :: IORef SiteMap  -- Inserted Breakpoints sites
     }
 
 data DsLclEnv = DsLclEnv {
        ds_meta    :: DsMetaEnv,        -- Template Haskell bindings
-       ds_loc     :: SrcSpan,          -- to put in pattern-matching error msgs
-        ds_locals  :: OccEnv Id,        -- For locals in breakpoints
-        ds_mod_name_ref :: Maybe Id     -- The Id used to store the Module name 
-                                        --  used by the breakpoint desugaring 
+       ds_loc     :: SrcSpan           -- to put in pattern-matching error msgs
      }
 
 -- Inside [| |] brackets, the desugarer looks 
@@ -209,12 +210,9 @@ mkDsEnvs mod rdr_env type_env msg_var
                gbl_env = DsGblEnv { ds_mod = mod, 
                                    ds_if_env = (if_genv, if_lenv),
                                    ds_unqual = mkPrintUnqualified rdr_env,
-                                   ds_msgs = msg_var,
-                                    ds_bkptSites = sites_var}
+                                   ds_msgs = msg_var}
                lcl_env = DsLclEnv { ds_meta = emptyNameEnv, 
-                                   ds_loc = noSrcSpan,
-                                    ds_locals = emptyOccEnv,
-                                    ds_mod_name_ref = Nothing }
+                                   ds_loc = noSrcSpan }
 
        return (gbl_env, lcl_env)
 
@@ -325,6 +323,11 @@ dsLookupDataCon :: Name -> DsM DataCon
 dsLookupDataCon name
   = dsLookupGlobal name                `thenDs` \ thing ->
     returnDs (tyThingDataCon thing)
+
+dsLookupClass :: Name -> DsM Class
+dsLookupClass name
+  = dsLookupGlobal name         `thenDs` \ thing ->
+    returnDs (tyThingClass thing)
 \end{code}
 
 \begin{code}
@@ -335,26 +338,3 @@ dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a
 dsExtendMetaEnv menv thing_inside
   = updLclEnv (\env -> env { ds_meta = ds_meta env `plusNameEnv` menv }) thing_inside
 \end{code}
-
-\begin{code}
-getLocalBindsDs :: DsM [Id]
-getLocalBindsDs = do { env <- getLclEnv; return (occEnvElts$ ds_locals env) }
-
-getModNameRefDs :: DsM (Maybe Id)
-getModNameRefDs = do { env <- getLclEnv; return (ds_mod_name_ref env) }
-
-withModNameRefDs :: Id -> DsM a -> DsM a
-withModNameRefDs id thing_inside =
-    updLclEnv (\env -> env {ds_mod_name_ref = Just id}) thing_inside
-
-bindLocalsDs :: [Id] -> DsM a -> DsM a
-bindLocalsDs new_ids enclosed_scope = 
-    updLclEnv (\env-> env {ds_locals = ds_locals env `extendOccEnvList` occnamed_ids})
-             enclosed_scope
-  where occnamed_ids = [ (nameOccName (idName id),id) | id <- new_ids ] 
-
-getBkptSitesDs :: DsM (IORef SiteMap)
-getBkptSitesDs = do { env <- getGblEnv; return (ds_bkptSites env) }
-
-\end{code}
-