@@ -21,7 +21,7 @@ module Development.IDE.Types.Exports
21
21
updateExportsMapMg
22
22
) where
23
23
24
- import Control.DeepSeq (NFData (.. ))
24
+ import Control.DeepSeq (NFData (.. ), force , ($!!) )
25
25
import Control.Monad
26
26
import Data.Bifunctor (Bifunctor (second ))
27
27
import Data.Char (isUpper )
@@ -45,6 +45,9 @@ data ExportsMap = ExportsMap
45
45
, getModuleExportsMap :: ! (ModuleNameEnv (HashSet IdentInfo ))
46
46
}
47
47
48
+ instance NFData ExportsMap where
49
+ rnf (ExportsMap a b) = foldOccEnv (\ a b -> rnf a `seq` b) (seqEltsUFM rnf b) a
50
+
48
51
instance Show ExportsMap where
49
52
show (ExportsMap occs mods) =
50
53
unwords [ " ExportsMap { getExportsMap ="
@@ -154,7 +157,7 @@ createExportsMap :: [ModIface] -> ExportsMap
154
157
createExportsMap modIface = do
155
158
let exportList = concatMap doOne modIface
156
159
let exportsMap = mkOccEnv_C (<>) $ map (\ (a,_,c) -> (a, c)) exportList
157
- ExportsMap exportsMap $ buildModuleExportMap $ map (\ (_,b,c) -> (b, c)) exportList
160
+ force $ ExportsMap exportsMap $ buildModuleExportMap $ map (\ (_,b,c) -> (b, c)) exportList -- UFM is lazy, so need to seq
158
161
where
159
162
doOne modIFace = do
160
163
let getModDetails = unpackAvail $ moduleName $ mi_module modIFace
@@ -164,7 +167,7 @@ createExportsMapMg :: [ModGuts] -> ExportsMap
164
167
createExportsMapMg modGuts = do
165
168
let exportList = concatMap doOne modGuts
166
169
let exportsMap = mkOccEnv_C (<>) $ map (\ (a,_,c) -> (a, c)) exportList
167
- ExportsMap exportsMap $ buildModuleExportMap $ map (\ (_,b,c) -> (b, c)) exportList
170
+ force $ ExportsMap exportsMap $ buildModuleExportMap $ map (\ (_,b,c) -> (b, c)) exportList -- UFM is lazy, so need to seq
168
171
where
169
172
doOne mi = do
170
173
let getModuleName = moduleName $ mg_module mi
@@ -188,7 +191,7 @@ createExportsMapHieDb withHieDb = do
188
191
fmap (unwrap mn) <$> withHieDb (\ hieDb -> getExportsForModule hieDb mn)
189
192
let idents = concat idents'
190
193
let exportsMap = mkOccEnv_C (<>) (keyWith name idents)
191
- return $! ExportsMap exportsMap $ buildModuleExportMap (keyWith identModuleName idents)
194
+ return $!! ExportsMap exportsMap $ buildModuleExportMap (keyWith identModuleName idents) -- UFM is lazy so need to seq
192
195
where
193
196
unwrap m ExportRow {.. } = IdentInfo exportName exportParent m
194
197
keyWith f xs = [(f x, Set. singleton x) | x <- xs]
0 commit comments