Skip to content

Commit c68f9be

Browse files
committed
ghcide: {Core.Compile,Spans.Documentation}: mark Lazy & Strict Maps
1 parent 2928b02 commit c68f9be

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ import qualified Data.DList as DL
8484
import Data.IORef
8585
import qualified Data.IntMap.Strict as IntMap
8686
import Data.List.Extra
87-
import qualified Data.Map.Strict as Map
87+
import qualified Data.Map.Strict as MS
8888
import Data.Maybe
8989
import qualified Data.Text as T
9090
import Data.Time (UTCTime, getCurrentTime)
@@ -93,7 +93,6 @@ import System.Directory
9393
import System.FilePath
9494
import System.IO.Extra (fixIO, newTempFileWithin)
9595

96-
-- GHC API imports
9796
-- GHC API imports
9897
import GHC (GetDocsFailure (..),
9998
mgModSummaries,
@@ -108,6 +107,7 @@ import Data.Functor
108107
import qualified Data.HashMap.Strict as HashMap
109108
import Data.IntMap (IntMap)
110109
import Data.Map (Map)
110+
import qualified Data.Map as ML
111111
import Data.Tuple.Extra (dupe)
112112
import Data.Either.Extra (maybeToEither)
113113
import Data.Unique as Unique
@@ -751,7 +751,7 @@ mergeEnvs env extraModSummaries extraMods envs = do
751751
-- To work around this, we coerce to the underlying type
752752
-- To remove this, I plan to upstream the missing Monoid instance
753753
concatFC :: [FinderCache] -> FinderCache
754-
concatFC = unsafeCoerce (mconcat @(Map InstalledModule InstalledFindResult))
754+
concatFC = unsafeCoerce (mconcat @(ML.Map InstalledModule InstalledFindResult))
755755

756756
withBootSuffix :: HscSource -> ModLocation -> ModLocation
757757
withBootSuffix HsBootFile = addBootSuffixLocnOut
@@ -1033,7 +1033,7 @@ getDocsNonInteractive'
10331033
(Env TcGblEnv TcLclEnv)
10341034
(Name,
10351035
Either
1036-
GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))
1036+
GetDocsFailure (Maybe HsDocString, Maybe (MS.Map Int HsDocString)))
10371037
getDocsNonInteractive' name =
10381038
case nameModule_maybe name of
10391039
Nothing -> return (name, Left $ NameHasNoModule name)
@@ -1051,12 +1051,12 @@ getDocsNonInteractive' name =
10511051
RealSrcLoc {} -> False
10521052
UnhelpfulLoc {} -> True
10531053
pure . (name,) $
1054-
if isNothing mb_doc_hdr && Map.null dmap && Map.null amap
1054+
if isNothing mb_doc_hdr && MS.null dmap && MS.null amap
10551055
then Left $ NoDocsInIface mod isNameCompiled
1056-
else Right (Map.lookup name dmap, Map.lookup name amap)
1056+
else Right (MS.lookup name dmap, MS.lookup name amap)
10571057

10581058
-- | Non-interactive modification of 'GHC.Runtime.Eval.getDocs'.
1059-
getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Either GHC.ErrorMessages (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString))))
1059+
getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Either GHC.ErrorMessages (Name, Either GetDocsFailure (Maybe HsDocString, Maybe (MS.Map Int HsDocString))))
10601060
getDocsNonInteractive hsc_env mod name = do
10611061
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
10621062
pure $ maybeToEither errs res
@@ -1068,10 +1068,10 @@ getDocsBatch
10681068
-> Module -- ^ a moudle where the names are in scope
10691069
-> [Name]
10701070
-- 2021-11-18: NOTE: Map Int would become IntMap if next GHCs.
1071-
-> IO (Either GHC.ErrorMessages (Map.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (Map.Map Int HsDocString)))))
1071+
-> IO (Either GHC.ErrorMessages (MS.Map Name (Either GetDocsFailure (Maybe HsDocString, Maybe (MS.Map Int HsDocString)))))
10721072
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
10731073
getDocsBatch hsc_env mod names = do
1074-
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ Map.fromList <$> traverse getDocsNonInteractive' names
1074+
((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ MS.fromList <$> traverse getDocsNonInteractive' names
10751075
pure $ maybeToEither errs res
10761076

10771077
-- | Non-interactive, batch version of 'InteractiveEval.lookupNames'.

ghcide/src/Development/IDE/Spans/Documentation.hs

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import Data.Bool (bool)
1818
import Data.Either
1919
import Data.Foldable
2020
import Data.List.Extra
21-
import qualified Data.Map as M
21+
import qualified Data.Map as ML
22+
import qualified Data.Map.Strict as MS
2223
import Data.Maybe
2324
import qualified Data.Set as S
2425
import qualified Data.Text as T
@@ -60,7 +61,7 @@ mkDocMap env rm this_mod =
6061
pure $ maybe mapToTyThing (extendNameEnv mapToTyThing n) kind
6162
| otherwise = pure mapToTyThing
6263
names = rights $ S.toList idents
63-
idents = M.keysSet rm
64+
idents = ML.keysSet rm
6465
mod = tcg_mod this_mod
6566

6667
lookupKind :: HscEnv -> Module -> Name -> IO (Maybe TyThing)
@@ -104,12 +105,12 @@ getDocumentationTryGhc env mod name = do
104105
Left _ -> pure emptySpanDoc
105106
Right res -> uncurry (intoSpanDoc env) res
106107

107-
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO (M.Map Name SpanDoc)
108+
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO (MS.Map Name SpanDoc)
108109
getDocumentationsTryGhc env mod names = do
109110
res <- getDocsBatch env mod names
110111
case res of
111112
Left _ -> return mempty
112-
Right res -> sequenceA $ M.mapWithKey (intoSpanDoc env) res
113+
Right res -> sequenceA $ MS.mapWithKey (intoSpanDoc env) res
113114

114115
getDocumentation
115116
:: HasSrcSpan name

0 commit comments

Comments
 (0)