[commit: ghc] master: Use `setSession` instead of `modifySession` when setting `HscEnv` (f669764)

git at git.haskell.org git at git.haskell.org
Sun May 22 08:58:01 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f669764f74ec6973ce62fa3488c3fefdd393212b/ghc

>---------------------------------------------------------------

commit f669764f74ec6973ce62fa3488c3fefdd393212b
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Sun May 22 05:00:51 2016 -0400

    Use `setSession` instead of `modifySession` when setting `HscEnv`
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2253


>---------------------------------------------------------------

f669764f74ec6973ce62fa3488c3fefdd393212b
 compiler/ghci/Debugger.hs        |  2 +-
 compiler/main/GhcMake.hs         |  2 +-
 compiler/main/InteractiveEval.hs | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs
index 6424472..acc900f 100644
--- a/compiler/ghci/Debugger.hs
+++ b/compiler/ghci/Debugger.hs
@@ -121,7 +121,7 @@ bindSuspensions t = do
           new_ic = extendInteractiveContextWithIds ictxt ids
       fhvs <- liftIO $ mapM (mkFinalizedHValue hsc_env <=< mkRemoteRef) hvals
       liftIO $ extendLinkEnv (zip names fhvs)
-      modifySession $ \_ -> hsc_env {hsc_IC = new_ic }
+      setSession hsc_env {hsc_IC = new_ic }
       return t'
      where
 
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 46a4990..af78065 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -122,7 +122,7 @@ depanal excluded_mods allow_dup_roots = do
     mod_graphE <- liftIO $ downsweep hsc_env old_graph
                                      excluded_mods allow_dup_roots
     mod_graph <- reportImportErrors mod_graphE
-    modifySession $ \_ -> hsc_env { hsc_mod_graph = mod_graph }
+    setSession hsc_env { hsc_mod_graph = mod_graph }
     return mod_graph
 
 -- | Describes which modules of the module graph need to be loaded.
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index e2b4c68..e564288 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -246,7 +246,7 @@ runDeclsWithLocation source linenumber expr =
     setSession $ hsc_env { hsc_IC = ic }
     hsc_env <- getSession
     hsc_env' <- liftIO $ rttiEnvironment hsc_env
-    modifySession (\_ -> hsc_env')
+    setSession hsc_env'
     return $ filter (not . isDerivedOccName . nameOccName)
              -- For this filter, see Note [What to show to users]
            $ map getName tyThings
@@ -356,7 +356,7 @@ handleRunStatus step expr bindings final_ids status history
              , resumeHistoryIx = 0 }
            hsc_env2 = pushResume hsc_env1 resume
 
-         modifySession (\_ -> hsc_env2)
+         setSession hsc_env2
          return (ExecBreak names bp)
 
     -- Completed successfully
@@ -366,7 +366,7 @@ handleRunStatus step expr bindings final_ids status history
              final_names = map getName final_ids
          liftIO $ Linker.extendLinkEnv (zip final_names hvals)
          hsc_env' <- liftIO $ rttiEnvironment hsc_env{hsc_IC=final_ic}
-         modifySession (\_ -> hsc_env')
+         setSession hsc_env'
          return (ExecComplete (Right final_names) allocs)
 
     -- Completed with an exception
@@ -398,7 +398,7 @@ resumeExec canLogSpan step
             ic' = ic { ic_tythings = resume_tmp_te,
                        ic_rn_gbl_env = resume_rdr_env,
                        ic_resume   = rs }
-        modifySession (\_ -> hsc_env{ hsc_IC = ic' })
+        setSession hsc_env{ hsc_IC = ic' }
 
         -- remove any bindings created since the breakpoint from the
         -- linker's environment
@@ -455,7 +455,7 @@ moveHist fn = do
                 r' = r { resumeHistoryIx = new_ix }
                 ic' = ic { ic_resume = r':rs }
 
-            modifySession (\_ -> hsc_env1{ hsc_IC = ic' })
+            setSession hsc_env1{ hsc_IC = ic' }
 
             return (names, new_ix, span, decl)
 
@@ -634,7 +634,7 @@ abandon = do
    case resume of
       []    -> return False
       r:rs  -> do
-         modifySession $ \_ -> hsc_env{ hsc_IC = ic { ic_resume = rs } }
+         setSession hsc_env{ hsc_IC = ic { ic_resume = rs } }
          liftIO $ abandonStmt hsc_env (resumeContext r)
          return True
 
@@ -646,7 +646,7 @@ abandonAll = do
    case resume of
       []  -> return False
       rs  -> do
-         modifySession $ \_ -> hsc_env{ hsc_IC = ic { ic_resume = [] } }
+         setSession hsc_env{ hsc_IC = ic { ic_resume = [] } }
          liftIO $ mapM_ (abandonStmt hsc_env. resumeContext) rs
          return True
 
@@ -697,7 +697,7 @@ setContext imports
            Right all_env -> do {
        ; let old_ic         = hsc_IC hsc_env
              !final_rdr_env = all_env `icExtendGblRdrEnv` ic_tythings old_ic
-       ; modifySession $ \_ ->
+       ; setSession
          hsc_env{ hsc_IC = old_ic { ic_imports    = imports
                                   , ic_rn_gbl_env = final_rdr_env }}}}
   where



More information about the ghc-commits mailing list