aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZubin Duggal <zubin@cmi.ac.in>2020-05-02 18:32:24 +0530
committerMatthew Pickering <matthewtpickering@gmail.com>2020-05-04 18:48:25 +0100
commit97f301a63ea8461074bfaa1486eb798e4be65f15 (patch)
tree75fcaded047666fb52335e5330724d8dbb61db82
parentc60995fe05d9cc267e892448604b8b96a705ccc7 (diff)
Atomic update of NameCache in readHieFile
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker.hs b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
index 7b66c566..d315ced0 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker.hs
@@ -19,7 +19,7 @@ import System.Directory
import System.FilePath
import GHC.Iface.Ext.Types ( HieFile(..), HieASTs(..) )
-import GHC.Iface.Ext.Binary ( readHieFile, hie_file_result)
+import GHC.Iface.Ext.Binary ( readHieFile, hie_file_result, NameCacheUpdater(..))
import Data.Map as M
import GHC.Data.FastString ( mkFastString )
import GHC.Unit.Module ( Module, moduleName )
@@ -56,12 +56,14 @@ ppHyperlinkedModuleSource srcdir pretty srcs iface = case ifaceHieFile iface of
Just hfp -> do
-- Parse the GHC-produced HIE file
u <- mkSplitUniqSupply 'a'
+ let nc = (initNameCache u [])
+ ncu = NCU $ \f -> pure $ snd $ f nc
HieFile { hie_hs_file = file
, hie_asts = HieASTs asts
, hie_types = types
, hie_hs_src = rawSrc
- } <- (hie_file_result . fst)
- <$> (readHieFile (initNameCache u []) hfp)
+ } <- hie_file_result
+ <$> (readHieFile ncu hfp)
-- Get the AST and tokens corresponding to the source file we want
let mast | M.size asts == 1 = snd <$> M.lookupMin asts