Add quasi-quotation, courtesy of Geoffrey Mainland
[ghc-hetmet.git] / compiler / typecheck / TcRnMonad.lhs
index 396805f..ed1dce6 100644 (file)
@@ -397,6 +397,9 @@ tcIsHsBoot = do { env <- getGblEnv; return (isHsBoot (tcg_src env)) }
 getGlobalRdrEnv :: TcRn GlobalRdrEnv
 getGlobalRdrEnv = do { env <- getGblEnv; return (tcg_rdr_env env) }
 
+getRdrEnvs :: TcRn (GlobalRdrEnv, LocalRdrEnv)
+getRdrEnvs = do { (gbl,lcl) <- getEnvs; return (tcg_rdr_env gbl, tcl_rdr lcl) }
+
 getImports :: TcRn ImportAvails
 getImports = do { env <- getGblEnv; return (tcg_imports env) }
 
@@ -561,6 +564,19 @@ recoverM recover thing
           Left exn  -> recover
           Right res -> returnM res }
 
+
+-----------------------
+mapAndRecoverM :: (a -> TcRn b) -> [a] -> TcRn [b]
+-- Drop elements of the input that fail, so the result
+-- list can be shorter than the argument list
+mapAndRecoverM f []     = return []
+mapAndRecoverM f (x:xs) = do { mb_r <- tryM (f x)
+                            ; rs <- mapAndRecoverM f xs
+                            ; return (case mb_r of
+                                         Left _  -> rs
+                                         Right r -> r:rs) }
+                       
+
 -----------------------
 tryTc :: TcRn a -> TcRn (Messages, Maybe a)
 -- (tryTc m) executes m, and returns
@@ -875,9 +891,11 @@ setLclTypeEnv lcl_env thing_inside
 recordThUse :: TcM ()
 recordThUse = do { env <- getGblEnv; writeMutVar (tcg_th_used env) True }
 
-keepAliveTc :: Name -> TcM ()          -- Record the name in the keep-alive set
-keepAliveTc n = do { env <- getGblEnv; 
-                  ; updMutVar (tcg_keep env) (`addOneToNameSet` n) }
+keepAliveTc :: Id -> TcM ()    -- Record the name in the keep-alive set
+keepAliveTc id 
+  | isLocalId id = do { env <- getGblEnv; 
+                     ; updMutVar (tcg_keep env) (`addOneToNameSet` idName id) }
+  | otherwise = return ()
 
 keepAliveSetTc :: NameSet -> TcM ()    -- Record the name in the keep-alive set
 keepAliveSetTc ns = do { env <- getGblEnv;