Skip to content

Commit

Permalink
Fix compilation with GHC-8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jun 2, 2016
1 parent 6c4d271 commit 1b39c9a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion hdevtools.cabal
Expand Up @@ -83,6 +83,10 @@ executable hdevtools
if impl(ghc >= 7.7)
build-depends: Cabal >= 1.18

if impl(ghc >= 7.9)
if impl(ghc >= 7.9 && < 8.0)
build-depends: Cabal >= 1.22,
bin-package-db

if impl(ghc >= 8.0)
build-depends: Cabal >= 1.24,
ghc-boot >= 8.0
12 changes: 11 additions & 1 deletion src/CommandLoop.hs
Expand Up @@ -20,6 +20,9 @@ import System.Exit (ExitCode(ExitFailure, ExitSuccess))
import System.FilePath (takeDirectory)
import qualified ErrUtils
import qualified Exception (ExceptionMonad)
#if __GLASGOW_HASKELL__ >= 800
import qualified DynFlags
#endif
import qualified GHC
import qualified GHC.Paths
import qualified Outputable
Expand Down Expand Up @@ -255,7 +258,14 @@ runCommand state clientSend (CmdFindSymbol symbol files) = do



#if __GLASGOW_HASKELL__ >= 706
#if __GLASGOW_HASKELL__ >= 800
logAction :: IORef State -> ClientSend -> GHC.DynFlags -> DynFlags.WarnReason -> GHC.Severity -> GHC.SrcSpan -> Outputable.PprStyle -> ErrUtils.MsgDoc -> IO ()
logAction state clientSend dflags _ severity srcspan style msg =
let out = Outputable.renderWithStyle dflags fullMsg style
_ = severity
in logActionSend state clientSend severity out
where fullMsg = ErrUtils.mkLocMessage severity srcspan msg
#elif __GLASGOW_HASKELL__ >= 706
logAction :: IORef State -> ClientSend -> GHC.DynFlags -> GHC.Severity -> GHC.SrcSpan -> Outputable.PprStyle -> ErrUtils.MsgDoc -> IO ()
logAction state clientSend dflags severity srcspan style msg =
let out = Outputable.renderWithStyle dflags fullMsg style
Expand Down
13 changes: 12 additions & 1 deletion src/FindSymbol.hs
Expand Up @@ -30,7 +30,12 @@ findSymbol symbol files = do
-- or errors to stdout for the loaded source files, we're only
-- interested in the module graph of the loaded targets
dynFlags <- GHC.getSessionDynFlags
_ <- GHC.setSessionDynFlags dynFlags { GHC.log_action = \_ _ _ _ _ -> return () }
_ <- GHC.setSessionDynFlags dynFlags { GHC.log_action = \_ _ _ _ _ ->
#if __GLASGOW_HASKELL__ >= 800
return . return $ () }
#else
return () }
#endif

fileMods <- concat <$> mapM (findSymbolInFile symbol) files

Expand Down Expand Up @@ -74,6 +79,12 @@ findSymbolInPackages symbol =
. PKG.pkgIdMap
. GHC.pkgState
<$> GHC.getSessionDynFlags
#elif __GLASGOW_HASKELL__ >= 800
exposedModuleNames = do
dynFlags <- GHC.getSessionDynFlags
pkgConfigs <- liftIO $ fmap concat
. (fmap . fmap) snd . PKG.readPackageConfigs $ dynFlags
return $ map exposedName (concatMap exposedModules pkgConfigs)
#else
exposedModuleNames = do
dynFlags <- GHC.getSessionDynFlags
Expand Down
5 changes: 4 additions & 1 deletion src/Info.hs
Expand Up @@ -176,7 +176,10 @@ pretty dflags =
pretty :: GHC.Type -> String
pretty =
#endif
#if __GLASGOW_HASKELL__ >= 708
#if __GLASGOW_HASKELL__ >= 800
Pretty.renderStyle
Pretty.style{ Pretty.lineLength = 0, Pretty.mode = Pretty.OneLineMode }
#elif __GLASGOW_HASKELL__ >= 708
Pretty.showDoc Pretty.OneLineMode 0
#else
Pretty.showDocWith Pretty.OneLineMode
Expand Down

0 comments on commit 1b39c9a

Please sign in to comment.