diff --git a/Language/Haskell/GhcMod/Browse.hs b/Language/Haskell/GhcMod/Browse.hs index 882e4ac..53bf2d4 100644 --- a/Language/Haskell/GhcMod/Browse.hs +++ b/Language/Haskell/GhcMod/Browse.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} module Language.Haskell.GhcMod.Browse ( browse, BrowseOpts(..) @@ -25,6 +26,9 @@ import TyCon (isAlgTyCon) import Type (dropForAlls, splitFunTy_maybe, mkFunTy, isPredTy) import Exception (ExceptionMonad, ghandle) import Prelude +#if __GLASGOW_HASKELL__ >= 800 +import PatSyn (pprPatSynType) +#endif ---------------------------------------------------------------- @@ -131,6 +135,9 @@ showThing' dflag (GtA a) = Just $ formatType dflag a showThing' _ (GtT t) = unwords . toList <$> tyType t where toList t' = t' : getOccString t : map getOccString (G.tyConTyVars t) +#if __GLASGOW_HASKELL__ >= 800 +showThing' dflag (GtPatSyn p) = Just $ showSDoc dflag $ pprPatSynType p +#endif showThing' _ _ = Nothing formatType :: DynFlags -> Type -> String diff --git a/Language/Haskell/GhcMod/DebugLogger.hs b/Language/Haskell/GhcMod/DebugLogger.hs index 5bcef08..b448358 100644 --- a/Language/Haskell/GhcMod/DebugLogger.hs +++ b/Language/Haskell/GhcMod/DebugLogger.hs @@ -62,7 +62,11 @@ import Language.Haskell.GhcMod.Gap import Prelude debugLogAction :: (String -> IO ()) -> GmLogAction +#if __GLASGOW_HASKELL__ >= 800 +debugLogAction putErr dflags _reason severity srcSpan style' msg +#else debugLogAction putErr dflags severity srcSpan style' msg +#endif = case severity of SevOutput -> printSDoc putErr msg style' diff --git a/Language/Haskell/GhcMod/DynFlags.hs b/Language/Haskell/GhcMod/DynFlags.hs index 09975db..794dda4 100644 --- a/Language/Haskell/GhcMod/DynFlags.hs +++ b/Language/Haskell/GhcMod/DynFlags.hs @@ -16,7 +16,11 @@ import Prelude setEmptyLogger :: DynFlags -> DynFlags setEmptyLogger df = +#if __GLASGOW_HASKELL__ >= 800 + Gap.setLogAction df $ \_ _ _ _ _ _ -> return () +#else Gap.setLogAction df $ \_ _ _ _ _ -> return () +#endif setDebugLogger :: (String -> IO ()) -> DynFlags -> DynFlags setDebugLogger put df = do diff --git a/Language/Haskell/GhcMod/Gap.hs b/Language/Haskell/GhcMod/Gap.hs index ab897a1..0b44dfd 100644 --- a/Language/Haskell/GhcMod/Gap.hs +++ b/Language/Haskell/GhcMod/Gap.hs @@ -83,7 +83,11 @@ import CoAxiom (coAxiomTyCon) #if __GLASGOW_HASKELL__ >= 708 import FamInstEnv import ConLike (ConLike(..)) +#if __GLASGOW_HASKELL__ >= 800 +import PatSyn (PatSyn) +#else import PatSyn (patSynType) +#endif #else import TcRnTypes #endif @@ -460,12 +464,19 @@ deSugar tcm e hs_env = snd <$> deSugarExpr hs_env modu rn_env ty_env e ---------------------------------------------------------------- data GapThing = GtA Type | GtT TyCon | GtN +#if __GLASGOW_HASKELL__ >= 800 + | GtPatSyn PatSyn +#endif fromTyThing :: TyThing -> GapThing fromTyThing (AnId i) = GtA $ varType i #if __GLASGOW_HASKELL__ >= 708 fromTyThing (AConLike (RealDataCon d)) = GtA $ dataConRepType d +#if __GLASGOW_HASKELL__ >= 800 +fromTyThing (AConLike (PatSynCon p)) = GtPatSyn p +#else fromTyThing (AConLike (PatSynCon p)) = GtA $ patSynType p +#endif #else fromTyThing (ADataCon d) = GtA $ dataConRepType d #endif diff --git a/Language/Haskell/GhcMod/Logger.hs b/Language/Haskell/GhcMod/Logger.hs index fd60b36..bf52410 100644 --- a/Language/Haskell/GhcMod/Logger.hs +++ b/Language/Haskell/GhcMod/Logger.hs @@ -25,6 +25,9 @@ import HscTypes import Outputable import qualified GHC as G import Bag +#if __GLASGOW_HASKELL__ >= 800 +import DynFlags (WarnReason) +#endif import Language.Haskell.GhcMod.Convert import Language.Haskell.GhcMod.Doc (showPage) @@ -59,8 +62,13 @@ readAndClearLogRef (LogRef ref) = do writeIORef ref emptyLog return $ b [] +#if __GLASGOW_HASKELL__ >= 800 +appendLogRef :: (FilePath -> FilePath) -> DynFlags -> LogRef -> DynFlags -> WarnReason -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO () +appendLogRef rfm df (LogRef ref) _ _reason sev src st msg = do +#else appendLogRef :: (FilePath -> FilePath) -> DynFlags -> LogRef -> DynFlags -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO () appendLogRef rfm df (LogRef ref) _ sev src st msg = do +#endif modifyIORef ref update where gpe = GmPprEnv { diff --git a/Language/Haskell/GhcMod/SrcUtils.hs b/Language/Haskell/GhcMod/SrcUtils.hs index 3991b3d..b1688a1 100644 --- a/Language/Haskell/GhcMod/SrcUtils.hs +++ b/Language/Haskell/GhcMod/SrcUtils.hs @@ -1,5 +1,5 @@ -- TODO: remove CPP once Gap(ed) -{-# LANGUAGE CPP, TupleSections, FlexibleInstances, Rank2Types, ImpredicativeTypes #-} +{-# LANGUAGE CPP, TupleSections, FlexibleInstances, Rank2Types #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Language.Haskell.GhcMod.SrcUtils where