[commit: ghc] master: Add mapMG to allow making ModuleGraph abstract (430137c)

git at git.haskell.org git at git.haskell.org
Wed Jun 14 15:52:18 UTC 2017


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

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

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

commit 430137c45420153dafbd448b4d509f893fe675f4
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Wed Jun 14 08:51:43 2017 -0700

    Add mapMG to allow making ModuleGraph abstract
    
    Currently GHC exposes the internal details of `ModuleGraph`
    which inhibits making `ModuleGraph` support faster lookups.
    
    Haddock relies on the internal representation by using `map`
    on `ModuleGraph`. See also
    https://github.com/haskell/haddock/issues/635
    
    Adding `mapMG` should allow us to make `ModuleGraph` abstract.
    
    Test Plan: ./validate
    
    Reviewers: simonmar, austin, bgamari, alexbiehl
    
    Reviewed By: bgamari, alexbiehl
    
    Subscribers: alexbiehl, rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3645


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

430137c45420153dafbd448b4d509f893fe675f4
 compiler/main/GHC.hs      | 5 +++--
 compiler/main/HscTypes.hs | 5 ++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index d58f3e9..2102009 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -59,7 +59,8 @@ module GHC (
         compileToCoreModule, compileToCoreSimplified,
 
         -- * Inspecting the module structure of the program
-        ModuleGraph, ModSummary(..), ms_mod_name, ModLocation(..),
+        ModuleGraph, emptyMG, mapMG,
+        ModSummary(..), ms_mod_name, ModLocation(..),
         getModSummary,
         getModuleGraph,
         isLoaded,
@@ -630,7 +631,7 @@ setProgramDynFlags_ invalidate_needed dflags = do
 --
 invalidateModSummaryCache :: GhcMonad m => m ()
 invalidateModSummaryCache =
-  modifySession $ \h -> h { hsc_mod_graph = map inval (hsc_mod_graph h) }
+  modifySession $ \h -> h { hsc_mod_graph = mapMG inval (hsc_mod_graph h) }
  where
   inval ms = ms { ms_hs_date = addUTCTime (-1) (ms_hs_date ms) }
 
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 369a190..fa9c18a 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -12,7 +12,7 @@ module HscTypes (
         HscEnv(..), hscEPS,
         FinderCache, FindResult(..), InstalledFindResult(..),
         Target(..), TargetId(..), pprTarget, pprTargetId,
-        ModuleGraph, emptyMG,
+        ModuleGraph, emptyMG, mapMG,
         HscStatus(..),
         IServ(..),
 
@@ -2611,6 +2611,9 @@ type ModuleGraph = [ModSummary]
 emptyMG :: ModuleGraph
 emptyMG = []
 
+mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph
+mapMG = map
+
 -- | A single node in a 'ModuleGraph'. The nodes of the module graph
 -- are one of:
 --



More information about the ghc-commits mailing list