@@ -17,12 +17,19 @@ import GHC.Paths (libdir)
1717#if __GLASGOW_HASKELL__ >= 800
1818import GHC.LanguageExtensions
1919#endif
20+#if __GLASGOW_HASKELL__ >= 802
21+import BasicTypes
22+#endif
2023import DynFlags
2124import Panic
2225import Outputable --hiding ((<>))
2326import PprTyThing
2427import Unsafe.Coerce
28+#if __GLASGOW_HASKELL__ >= 802
29+import Type
30+#else
2531import Type hiding (pprTyThing)
32+#endif
2633
2734data ScriptSession = ScriptSession {
2835 hscEnv :: HscEnv,
@@ -62,7 +69,12 @@ initScriptSession ghcPkgPaths = do
6269 trustFlags = map TrustPackage required_packages,
6370#endif
6471 packageFlags = packageFlags dflags ++ packages,
72+#if __GLASGOW_HASKELL__ >= 802
73+ packageDBFlags = map PackageDB localPkgPaths
74+#else
6575 extraPkgConfs = const (localPkgPaths ++ [UserPkgConf, GlobalPkgConf])
76+#endif
77+
6678 }
6779 applyGopts flags = foldl gopt_set flags gopts
6880 applyXopts flags = foldl xopt_set flags xopts
@@ -94,7 +106,11 @@ initScriptSession ghcPkgPaths = do
94106 --liftIO $ traceShowM (showSDoc dflags' (ppr packages))
95107 _ <- setSessionDynFlags dflags'
96108 let safeImportDecl mn mQual = ImportDecl {
109+#if __GLASGOW_HASKELL__ >= 802
110+ ideclSourceSrc = NoSourceText,
111+#else
97112 ideclSourceSrc = Nothing,
113+#endif
98114 ideclName = noLoc mn,
99115 ideclPkgQual = Nothing,
100116 ideclSource = False,
@@ -116,7 +132,12 @@ initScriptSession ghcPkgPaths = do
116132 "ProjectM36.DatabaseContextFunctionError",
117133 "ProjectM36.DatabaseContextFunctionUtils",
118134 "ProjectM36.RelationalExpression"]
119− qualifiedModules = map (\(modn, qualNam) -> IIDecl $ safeImportDecl (mkModuleName modn) (Just (mkModuleName qualNam))) [
135+#if __GLASGOW_HASKELL__ >= 802
136+ mkModName = noLoc . mkModuleName
137+#else
138+ mkModName = mkModuleName
139+#endif
140+ qualifiedModules = map (\(modn, qualNam) -> IIDecl $ safeImportDecl (mkModuleName modn) (Just (mkModName qualNam))) [
120141 ("Data.Text", "T")
121142 ]
122143 setContext (unqualifiedModules ++ qualifiedModules)
@@ -165,7 +186,11 @@ typeCheckScript :: Type -> Text -> Ghc (Maybe ScriptCompilationError)
165186typeCheckScript expectedType inp = do
166187 dflags <- getSessionDynFlags
167188 --catch exception for SyntaxError
189+#if __GLASGOW_HASKELL__ >= 802
190+ funcType <- GHC.exprType TM_Inst (unpack inp)
191+#else
168192 funcType <- GHC.exprType (unpack inp)
193+#endif
169194 --liftIO $ putStrLn $ showType dflags expectedType ++ ":::" ++ showType dflags funcType
170195 if eqType funcType expectedType then
171196 pure Nothing