From 97f301a63ea8461074bfaa1486eb798e4be65f15 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Sat, 2 May 2020 18:32:24 +0530 Subject: Atomic update of NameCache in readHieFile --- haddock-api/src/Haddock/Backends/Hyperlinker.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker.hs') 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 -- cgit v1.2.3