Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup CPP for GHCs < 9.2, fix most GHC warnings #429

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Main where
import Control.Monad ( forM )
import qualified Colog.Core as L
import Data.Version (showVersion)
import Data.Text.Prettyprint.Doc
import Prettyprinter
import Options.Applicative
import System.Directory (getCurrentDirectory)
import System.IO (stdout, hSetEncoding, utf8)
Expand Down
10 changes: 5 additions & 5 deletions hie-bios.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Description: Set up a GHC API session and obtain flags required to co
Category: Development
Build-Type: Simple
-- No glob syntax until GHC 8.6 because of stack
Extra-Source-Files: ChangeLog.md
README.md
extra-doc-files: ChangeLog.md
Extra-Source-Files: README.md
fendor marked this conversation as resolved.
Show resolved Hide resolved
wrappers/cabal
wrappers/cabal.hs
tests/configs/*.yaml
Expand Down Expand Up @@ -163,7 +163,7 @@ Library
Other-Modules: Paths_hie_bios
autogen-modules: Paths_hie_bios
Build-Depends:
base >= 4.14 && < 5,
base >= 4.16 && < 5,
aeson >= 1.4.4 && < 2.3,
base16-bytestring >= 0.1.1 && < 1.1,
bytestring >= 0.10.8 && < 0.13,
Expand All @@ -176,7 +176,7 @@ Library
time >= 1.8.0 && < 1.13,
extra >= 1.6.14 && < 1.8,
prettyprinter ^>= 1.6 || ^>= 1.7.0,
ghc >= 8.10.1 && < 9.9,
ghc >= 9.2.1 && < 9.9,
transformers >= 0.5.2 && < 0.7,
temporary >= 1.2 && < 1.4,
template-haskell,
Expand All @@ -195,7 +195,7 @@ Executable hie-bios
Other-Modules: Paths_hie_bios
GHC-Options: -Wall
HS-Source-Dirs: exe
Build-Depends: base >= 4.9 && < 5
Build-Depends: base >= 4.16 && < 5
, co-log-core
, directory
, filepath
Expand Down
5 changes: 2 additions & 3 deletions src/HIE/Bios/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
, makeCradleResult
-- | Cradle project configuration types
, CradleProjectConfig(..)
,
) where

import Control.Applicative ((<|>), optional)
Expand Down Expand Up @@ -143,9 +142,9 @@
-- each prefix we know how to handle
data ResolvedCradles a
= ResolvedCradles
{ cradleRoot :: FilePath

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, ubuntu-latest)

Defined but not used: record field of ResolvedCradles ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, ubuntu-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, ubuntu-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, ubuntu-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, macOS-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, macOS-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, macOS-latest)

Defined but not used: record field of ResolvedCradles ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, macOS-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, windows-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, windows-latest)

Defined but not used: record field of ResolvedCradles ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, windows-latest)

Defined but not used: ‘cradleRoot’

Check warning on line 145 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, windows-latest)

Defined but not used: ‘cradleRoot’
, resolvedCradles :: [ResolvedCradle a] -- ^ In order of decreasing specificity

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, ubuntu-latest)

Defined but not used:

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, ubuntu-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, ubuntu-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, ubuntu-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, macOS-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, macOS-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, macOS-latest)

Defined but not used:

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, macOS-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, windows-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, windows-latest)

Defined but not used:

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, windows-latest)

Defined but not used: ‘resolvedCradles’

Check warning on line 146 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, windows-latest)

Defined but not used: ‘resolvedCradles’
, cradleProgramVersions :: ProgramVersions

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, ubuntu-latest)

Defined but not used:

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, ubuntu-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, ubuntu-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, ubuntu-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, macOS-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, macOS-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, macOS-latest)

Defined but not used:

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, macOS-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.2.8, windows-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.8.2, windows-latest)

Defined but not used:

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.4.8, windows-latest)

Defined but not used: ‘cradleProgramVersions’

Check warning on line 147 in src/HIE/Bios/Cradle.hs

View workflow job for this annotation

GitHub Actions / build (9.6.4, windows-latest)

Defined but not used: ‘cradleProgramVersions’
}

data ProgramVersions =
Expand Down Expand Up @@ -806,8 +805,8 @@
-- Start a multi-component session with all the old files
_ -> "--keep-temp-files"
: "--enable-multi-repl"
: [fromMaybe (fixTargetPath fp) mc]
++ [fromMaybe (fixTargetPath old_fp) old_mc
: fromMaybe (fixTargetPath fp) mc
: [fromMaybe (fixTargetPath old_fp) old_mc
| old_fp <- fps
-- Lookup the component for the old file
, Just (ResolvedCradle{concreteCradle = ConcreteCabal ct}) <- [selectCradle prefix old_fp cs]
Expand Down
2 changes: 1 addition & 1 deletion src/HIE/Bios/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ addCmdOpts cmdOpts df1 = do
let leftovers = map G.unLoc leftovers' ++ additionalTargets

let (df3, srcs, _objs) = Gap.parseTargetFiles df2 leftovers
ts <- mapM (uncurry (\f phase -> Gap.guessTarget f (Just $ Gap.homeUnitId_ df3) phase) ) srcs
ts <- mapM (\(f, phase) -> Gap.guessTarget f (Just $ Gap.homeUnitId_ df3) phase) srcs
return (df3, ts)

-- | Make filepaths in the given 'DynFlags' absolute.
Expand Down
8 changes: 0 additions & 8 deletions src/HIE/Bios/Ghc/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ module HIE.Bios.Ghc.Api (

import GHC (LoadHowMuch(..), DynFlags, GhcMonad)
import qualified GHC as G

#if __GLASGOW_HASKELL__ >= 900
import qualified GHC.Driver.Main as G
import qualified GHC.Driver.Make as G
#else
import qualified HscMain as G
import qualified GhcMake as G
#endif

import qualified HIE.Bios.Ghc.Gap as Gap
import Control.Monad (void)
import Control.Monad.IO.Class
Expand Down
6 changes: 3 additions & 3 deletions src/HIE/Bios/Ghc/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import qualified GHC as G
import Control.Exception
import Control.Monad.IO.Class
import Colog.Core (LogAction (..), WithSeverity (..), Severity (..), (<&), cmap)
import Data.Text.Prettyprint.Doc
import Prettyprinter

import HIE.Bios.Ghc.Api
import HIE.Bios.Ghc.Logger
Expand Down Expand Up @@ -44,12 +44,12 @@ checkSyntax :: Show a
-> [FilePath] -- ^ The target files.
-> IO String
checkSyntax _ _ [] = return ""
checkSyntax checkLogger cradle files = do
checkSyntax checkLogger cradle files@(file:_) = do
libDirRes <- getRuntimeGhcLibDir cradle
handleRes libDirRes $ \libDir ->
G.runGhcT (Just libDir) $ do
liftIO $ checkLogger <& LogCradle cradle `WithSeverity` Info
res <- initializeFlagsWithCradle (head files) cradle
res <- initializeFlagsWithCradle file cradle
handleRes res $ \(ini, _) -> do
_sf <- ini
either id id <$> check checkLogger files
Expand Down
10 changes: 4 additions & 6 deletions src/HIE/Bios/Ghc/Doc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import GHC (DynFlags
import GHC.Utils.Outputable
#endif

#if __GLASGOW_HASKELL__ >= 900
import GHC.Driver.Session (initSDocContext)
import GHC.Utils.Outputable (PprStyle, SDoc, runSDoc, neverQualify, )
import GHC.Utils.Ppr (Mode(..), Doc, Style(..), renderStyle, style)
#else
import Outputable (PprStyle, SDoc, runSDoc, neverQualify, initSDocContext)
import Pretty (Mode(..), Doc, Style(..), renderStyle, style)
#endif

import HIE.Bios.Ghc.Gap (makeUserStyle, pageMode, oneLineMode)

#if __GLASGOW_HASKELL__ < 905
import GHC.Utils.Outputable (PprStyle, SDoc, runSDoc, neverQualify, )
#endif

#if __GLASGOW_HASKELL__ >= 905
getPrintUnqual :: Monad m => m NamePprCtx
getPrintUnqual = pure neverQualify
Expand Down
Loading
Loading