Compatibility with GHC 8.2.1

This commit is contained in:
Ben Gamari
2017-08-19 17:27:08 -04:00
parent 3d9a339869
commit d00e956e4a
10 changed files with 102 additions and 17 deletions

View File

@@ -166,4 +166,5 @@ removeForAlls' ty (Just (pre, ftype))
| otherwise = ty
showOutputable :: Outputable a => DynFlags -> a -> String
showOutputable dflag = unwords . lines . showPage dflag styleUnqualified . ppr
showOutputable dflag =
unwords . lines . showPage dflag (styleUnqualified dflag) . ppr

View File

@@ -116,7 +116,9 @@ getSignature modSum lineNo colNo = do
p@ParsedModule{pm_parsed_source = ps} <- G.parseModule modSum
-- Inspect the parse tree to find the signature
case listifyParsedSpans ps (lineNo, colNo) :: [G.LHsDecl G.RdrName] of
#if __GLASGOW_HASKELL__ >= 800
#if __GLASGOW_HASKELL__ >= 802
[L loc (G.SigD (Ty.TypeSig names (G.HsWC _ (G.HsIB _ (L _ ty) _))))] ->
#elif __GLASGOW_HASKELL__ >= 800
[L loc (G.SigD (Ty.TypeSig names (G.HsIB _ (G.HsWC _ _ (L _ ty)))))] ->
#elif __GLASGOW_HASKELL__ >= 710
[L loc (G.SigD (Ty.TypeSig names (L _ ty) _))] ->
@@ -133,7 +135,9 @@ getSignature modSum lineNo colNo = do
case Gap.getClass lst of
Just (clsName,loc) -> obtainClassInfo minfo clsName loc
_ -> return Nothing
#if __GLASGOW_HASKELL__ >= 800
#if __GLASGOW_HASKELL__ >= 802
[L loc (G.TyClD (G.FamDecl (G.FamilyDecl info (L _ name) (G.HsQTvs _ vars _) _ _ _)))] -> do
#elif __GLASGOW_HASKELL__ >= 800
[L loc (G.TyClD (G.FamDecl (G.FamilyDecl info (L _ name) (G.HsQTvs _ vars _) _ _)))] -> do
#elif __GLASGOW_HASKELL__ >= 708
[L loc (G.TyClD (G.FamDecl (G.FamilyDecl info (L _ name) (G.HsQTvs _ vars) _)))] -> do
@@ -365,7 +369,11 @@ refine file lineNo colNo (Expression expr) =
modSum <- fileModSummaryWithMapping file
p <- G.parseModule modSum
tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p
#if __GLASGOW_HASKELL__ >= 802
ety <- G.exprType G.TM_Inst expr
#else
ety <- G.exprType expr
#endif
whenFound oopts (findVar dflag style tcm tcs lineNo colNo) $
\(loc, name, rty, paren) ->
let eArgs = getFnArgs ety

View File

@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}
module GhcMod.Exe.Test where
import Control.Applicative
@@ -36,6 +38,15 @@ test f = runGmlT' [Left f] (fmap setHscInterpreted . deferErrors) $ do
return ""
#if __GLASGOW_HASKELL__ >= 802
runTest :: GhcMonad m => String -> m (Maybe SomeException)
runTest fn = do
res <- execStmt ("quickCheck " ++ fn) execOptions
return $ case res of
ExecComplete (Right _) _ -> Nothing
ExecComplete (Left se) _ -> Just se
_ -> error "runTest"
#else
runTest :: GhcMonad m => String -> m (Maybe SomeException)
runTest fn = do
res <- runStmt ("quickCheck " ++ fn) RunToCompletion
@@ -43,3 +54,4 @@ runTest fn = do
RunOk [] -> Nothing
RunException se -> Just se
_ -> error "runTest"
#endif