Skip to content

Commit 5716fa2

Browse files
committed
Development.IDE.Spans.Documentation: getDocumentationsTryGhc: use Map
1 parent 2fdb439 commit 5716fa2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ lookupKind env mod =
6565
fmap (fromRight Nothing) . catchSrcErrors (hsc_dflags env) "span" . lookupName env mod
6666

6767
getDocumentationTryGhc :: HscEnv -> Module -> Name -> IO SpanDoc
68-
getDocumentationTryGhc env mod n = fmap head ((fmap . fmap) snd $ getDocumentationsTryGhc env mod [n])
68+
getDocumentationTryGhc env mod n = fmap head ((fmap . fmap) snd $ fmap Map.toList $ getDocumentationsTryGhc env mod [n])
6969

70-
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO [(Name, SpanDoc)]
70+
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO (Map.Map Name SpanDoc)
7171
getDocumentationsTryGhc env mod names = do
7272
res <- fun
7373
case res of
74-
Left _ -> return []
75-
Right res -> sequenceA $ unwrap <$> Map.toList res
74+
Left _ -> return mempty
75+
Right res -> fmap Map.fromList $ sequenceA $ unwrap <$> Map.toList res
7676
where
7777
fun :: IO (Either [FileDiagnostic] (Map.Map Name (Either String (Maybe HsDocString, Map.Map Int HsDocString))))
7878
fun = catchSrcErrors (hsc_dflags env) "docs" $ getDocsBatch env mod names
7979

8080
unwrap :: (Name, Either a (Maybe HsDocString, b)) -> IO (Name, SpanDoc)
8181
unwrap (name, Right (Just docs, _)) = (name,) . SpanDocString docs <$> getUris name
82-
unwrap (name, _) = (name,) . SpanDocText [] <$> getUris name
82+
unwrap (name, _) = (name,) . SpanDocText mempty <$> getUris name
8383

8484
-- Get the uris to the documentation and source html pages if they exist
8585
getUris name = do

0 commit comments

Comments
 (0)