@@ -106,7 +106,6 @@ import Data.Binary
106
106
import Data.Coerce
107
107
import Data.Functor
108
108
import qualified Data.HashMap.Strict as HashMap
109
- import Data.Map (Map )
110
109
import qualified Data.Map as ML
111
110
import Data.Tuple.Extra (dupe )
112
111
import Data.Either.Extra (maybeToEither )
@@ -993,7 +992,17 @@ mkDetailsFromIface session iface linkable = do
993
992
initIfaceLoad hsc' (typecheckIface iface)
994
993
return (HomeModInfo iface details linkable)
995
994
996
- initTypecheckEnv :: HscEnv -> Module -> TcRn r -> IO (Messages , Maybe r )
995
+ initTypecheckEnv
996
+ :: HscEnv
997
+ -> Module
998
+ -> TcRn r
999
+ -> IO
1000
+ ( Messages
1001
+ #if MIN_VERSION_ghc(9,2,1)
1002
+ DecoratedSDoc
1003
+ #endif
1004
+ , Maybe r
1005
+ )
997
1006
initTypecheckEnv hsc_env mod = initTc hsc_env HsSrcFile False mod fakeSpan
998
1007
where
999
1008
fakeSpan :: RealSrcSpan
@@ -1038,23 +1047,50 @@ getDocsNonInteractive' name =
1038
1047
else Right (MS. lookup name dmap, MS. lookup name amap')
1039
1048
1040
1049
-- | Non-interactive modification of 'GHC.Runtime.Eval.getDocs'.
1041
- getDocsNonInteractive :: HscEnv -> Module -> Name -> IO (Either GHC. ErrorMessages (Name , Either GetDocsFailure (Maybe HsDocString , Maybe (IntMap HsDocString ))))
1042
- getDocsNonInteractive hsc_env mod name = do
1043
- ((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
1044
- pure $ maybeToEither errs res
1050
+ getDocsNonInteractive
1051
+ :: HscEnv
1052
+ -> Module
1053
+ -> Name
1054
+ -> IO
1055
+ ( Either
1056
+ GHC. ErrorMessages
1057
+ ( Name
1058
+ , Either
1059
+ GetDocsFailure
1060
+ ( Maybe HsDocString
1061
+ , Maybe (IntMap HsDocString )
1062
+ )
1063
+ )
1064
+ )
1065
+ getDocsNonInteractive hsc_env mod name =
1066
+ do
1067
+ let
1068
+ init = initTypecheckEnv hsc_env mod $ getDocsNonInteractive' name
1069
+ #if MIN_VERSION_ghc (9,2,1)
1070
+ (Error. getErrorMessages -> errs, res) <- init
1071
+ #else
1072
+ ((_warns,errs), res) <- init
1073
+ #endif
1074
+ pure $ maybeToEither errs res
1045
1075
1046
1076
1047
1077
-- | Non-interactive, batch version of 'GHC.Runtime.Eval.getDocs'.
1048
1078
getDocsBatch
1049
1079
:: HscEnv
1050
1080
-> Module -- ^ a moudle where the names are in scope
1051
1081
-> [Name ]
1052
- -- 2021-11-18: NOTE: Map Int would become IntMap if next GHCs.
1053
- -> IO (Either GHC. ErrorMessages (MS. Map Name (Either GetDocsFailure (Maybe HsDocString , Maybe (IntMap HsDocString )))))
1082
+ -> IO (Either GHC. ErrorMessages (MS. Map Name (Either GetDocsFailure (Maybe HsDocString , Maybe (IntMap HsDocString )))))
1054
1083
-- ^ Return a 'Map' of 'Name's to 'Either' (no docs messages) (general doc body & arg docs)
1055
- getDocsBatch hsc_env mod names = do
1056
- ((_warns,errs), res) <- initTypecheckEnv hsc_env mod $ MS. fromList <$> traverse getDocsNonInteractive' names
1057
- pure $ maybeToEither errs res
1084
+ getDocsBatch hsc_env mod names =
1085
+ do
1086
+ let
1087
+ init = initTypecheckEnv hsc_env mod $ MS. fromList <$> traverse getDocsNonInteractive' names
1088
+ #if MIN_VERSION_ghc (9,2,1)
1089
+ (Error. getErrorMessages -> errs, res) <- init
1090
+ #else
1091
+ ((_warns,errs), res) <- init
1092
+ #endif
1093
+ pure $ maybeToEither errs res
1058
1094
1059
1095
-- | Non-interactive, batch version of 'InteractiveEval.lookupNames'.
1060
1096
-- The interactive paths create problems in ghc-lib builds
0 commit comments