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

@@ -1,8 +1,13 @@
{-# LANGUAGE CPP #-}
module GhcMod.Doc where
import GHC
import GhcMod.Gap (withStyle, showDocWith)
import Outputable
#if __GLASGOW_HASKELL__ >= 802
import DynFlags
#endif
import Pretty (Mode(..))
showPage :: DynFlags -> PprStyle -> SDoc -> String
@@ -14,7 +19,17 @@ showOneLine dflag style = showDocWith dflag OneLineMode . withStyle dflag style
getStyle :: GhcMonad m => m PprStyle
getStyle = do
unqual <- getPrintUnqual
#if __GLASGOW_HASKELL__ >= 802
dflags <- getDynFlags
return $ mkUserStyle dflags unqual AllTheWay
#else
return $ mkUserStyle unqual AllTheWay
#endif
styleUnqualified :: PprStyle
styleUnqualified = mkUserStyle neverQualify AllTheWay
styleUnqualified :: DynFlags -> PprStyle
styleUnqualified dflags =
#if __GLASGOW_HASKELL__ >= 802
mkUserStyle dflags neverQualify AllTheWay
#else
mkUserStyle neverQualify AllTheWay
#endif