Skip to content

Commit 98027f7

Browse files
committed
Remove unnecessary CPP directives, following move to GHC 9.2.4
1 parent 395eb6d commit 98027f7

File tree

21 files changed

+1
-283
lines changed

21 files changed

+1
-283
lines changed

src/Options/Applicative/Builder/Extra.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
2-
{-# LANGUAGE CPP #-}
32
{-# LANGUAGE RecordWildCards #-}
43
{-# LANGUAGE ScopedTypeVariables #-}
54

@@ -287,8 +286,4 @@ unescapeBashArg input = go input
287286
go (x : xs) = x : go xs
288287

289288
showHelpText :: ParseError
290-
#if MIN_VERSION_optparse_applicative(0,16,0)
291289
showHelpText = ShowHelpText Nothing
292-
#else
293-
showHelpText = ShowHelpText
294-
#endif

src/Stack/Build.hs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE DeriveDataTypeable #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE OverloadedStrings #-}
@@ -20,12 +19,8 @@ module Stack.Build
2019

2120
import Stack.Prelude hiding (loadPackage)
2221
import Data.Aeson (Value (Object, Array), (.=), object)
23-
#if MIN_VERSION_aeson(2,0,0)
2422
import qualified Data.Aeson.Key as Key
2523
import qualified Data.Aeson.KeyMap as KeyMap
26-
#else
27-
import qualified Data.HashMap.Strict as HM
28-
#endif
2924
import Data.List ((\\), isPrefixOf)
3025
import Data.List.Extra (groupSort)
3126
import qualified Data.List.NonEmpty as NE
@@ -299,11 +294,7 @@ queryBuildInfo selectors0 =
299294
select front (sel:sels) value =
300295
case value of
301296
Object o ->
302-
#if MIN_VERSION_aeson(2,0,0)
303297
case KeyMap.lookup (Key.fromText sel) o of
304-
#else
305-
case HM.lookup sel o of
306-
#endif
307298
Nothing -> err "Selector not found"
308299
Just value' -> cont value'
309300
Array v ->
@@ -338,23 +329,15 @@ rawBuildInfo = do
338329
wantedCompiler <- view $ wantedCompilerVersionL.to (utf8BuilderToText . display)
339330
actualCompiler <- view $ actualCompilerVersionL.to compilerVersionText
340331
return $ object
341-
#if MIN_VERSION_aeson(2,0,0)
342332
[ "locals" .= Object (KeyMap.fromList $ map localToPair locals)
343-
#else
344-
[ "locals" .= Object (HM.fromList $ map localToPair locals)
345-
#endif
346333
, "compiler" .= object
347334
[ "wanted" .= wantedCompiler
348335
, "actual" .= actualCompiler
349336
]
350337
]
351338
where
352339
localToPair lp =
353-
#if MIN_VERSION_aeson(2,0,0)
354340
(Key.fromText $ T.pack $ packageNameString $ packageName p, value)
355-
#else
356-
(T.pack $ packageNameString $ packageName p, value)
357-
#endif
358341
where
359342
p = lpPackage lp
360343
value = object
@@ -376,11 +359,7 @@ checkComponentsBuildable lps =
376359
checkSubLibraryDependencies :: HasLogFunc env => [ProjectPackage] -> RIO env ()
377360
checkSubLibraryDependencies proj = do
378361
forM_ proj $ \p -> do
379-
#if MIN_VERSION_Cabal(3,4,0)
380362
C.GenericPackageDescription _ _ _ lib subLibs foreignLibs exes tests benches <- liftIO $ cpGPD . ppCommon $ p
381-
#else
382-
C.GenericPackageDescription _ _ lib subLibs foreignLibs exes tests benches <- liftIO $ cpGPD . ppCommon $ p
383-
#endif
384363

385364
let dependencies = concatMap getDeps subLibs <>
386365
concatMap getDeps foreignLibs <>

src/Stack/Build/Execute.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE DataKinds #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE MultiParamTypeClasses #-}
@@ -1221,11 +1220,7 @@ withSingleContext ActionContext {..} ee@ExecuteEnv {..} task@Task {..} allDeps m
12211220
let macroDeps = mapMaybe snd matchedDeps
12221221
cppMacrosFile = setupDir </> relFileSetupMacrosH
12231222
cppArgs = ["-optP-include", "-optP" ++ toFilePath cppMacrosFile]
1224-
#if MIN_VERSION_Cabal(3,4,0)
12251223
writeBinaryFileAtomic cppMacrosFile (encodeUtf8Builder (T.pack (C.generatePackageVersionMacros (packageVersion package) macroDeps)))
1226-
#else
1227-
writeBinaryFileAtomic cppMacrosFile (encodeUtf8Builder (T.pack (C.generatePackageVersionMacros macroDeps)))
1228-
#endif
12291224
return (packageDBArgs ++ depsArgs ++ cppArgs)
12301225

12311226
-- This branch is usually taken for builds, and

src/Stack/Build/Installed.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE FlexibleContexts #-}
54
{-# LANGUAGE MultiParamTypeClasses #-}
65
{-# LANGUAGE OverloadedStrings #-}
@@ -148,9 +147,6 @@ processLoadResult mdb (reason, lh) = do
148147
maybe mempty (\db -> ", from " <> displayShow db <> ",") mdb <>
149148
" due to" <>
150149
case reason of
151-
#if !MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)
152-
Allowed -> " the impossible?!?!"
153-
#endif
154150
UnknownPkg -> " it being unknown to the resolver / extra-deps."
155151
WrongLocation mloc loc -> " wrong location: " <> displayShow (mloc, loc)
156152
WrongVersion actual wanted ->

src/Stack/BuildPlan.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE DataKinds #-}
54
{-# LANGUAGE DeriveDataTypeable #-}
65
{-# LANGUAGE FlexibleContexts #-}
@@ -225,11 +224,7 @@ selectPackageBuildPlan platform compiler pool gpd =
225224
flagCombinations :: NonEmpty [(FlagName, Bool)]
226225
flagCombinations = mapM getOptions (genPackageFlags gpd)
227226
where
228-
#if MIN_VERSION_Cabal(3,4,0)
229227
getOptions :: C.PackageFlag -> NonEmpty (FlagName, Bool)
230-
#else
231-
getOptions :: C.Flag -> NonEmpty (FlagName, Bool)
232-
#endif
233228
getOptions f
234229
| flagManual f = (fname, flagDefault f) :| []
235230
| flagDefault f = (fname, True) :| [(fname, False)]

src/Stack/Config.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE DataKinds #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE LambdaCase #-}
@@ -154,9 +153,6 @@ makeConcreteResolver (ARResolver r) = pure r
154153
makeConcreteResolver ar = do
155154
r <-
156155
case ar of
157-
#if !MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)
158-
ARResolver r -> assert False $ makeConcreteResolver (ARResolver r)
159-
#endif
160156
ARGlobal -> do
161157
config <- view configL
162158
implicitGlobalDir <- getImplicitGlobalProjectDir config

src/Stack/ConfigCmd.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE FlexibleContexts #-}
54
{-# LANGUAGE GADTs #-}
65
{-# LANGUAGE OverloadedStrings #-}
@@ -18,15 +17,10 @@ module Stack.ConfigCmd
1817
,cfgCmdName) where
1918

2019
import Stack.Prelude
21-
#if MIN_VERSION_aeson(2,0,0)
2220
import qualified Data.Aeson.Key as Key
2321
import qualified Data.Aeson.KeyMap as KeyMap
24-
#endif
2522
import Data.ByteString.Builder (byteString)
2623
import qualified Data.Map.Merge.Strict as Map
27-
#if !MIN_VERSION_aeson(2,0,0)
28-
import qualified Data.HashMap.Strict as HMap
29-
#endif
3024
import qualified Data.Text as T
3125
import qualified Data.Yaml as Yaml
3226
import qualified Options.Applicative as OA
@@ -81,11 +75,7 @@ cfgCmdSet cmd = do
8175
liftIO (Yaml.decodeFileEither (toFilePath configFilePath)) >>= either throwM return
8276
newValue <- cfgCmdSetValue (parent configFilePath) cmd
8377
let cmdKey = cfgCmdSetOptionName cmd
84-
#if MIN_VERSION_aeson(2,0,0)
8578
config' = KeyMap.insert (Key.fromText cmdKey) newValue config
86-
#else
87-
config' = HMap.insert cmdKey newValue config
88-
#endif
8979
if config' == config
9080
then logInfo
9181
(fromString (toFilePath configFilePath) <>

src/Stack/Init.hs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE FlexibleContexts #-}
54
{-# LANGUAGE MultiParamTypeClasses #-}
65
{-# LANGUAGE OverloadedStrings #-}
@@ -14,15 +13,10 @@ module Stack.Init
1413
) where
1514

1615
import Stack.Prelude
17-
#if MIN_VERSION_aeson(2,0,0)
1816
import qualified Data.Aeson.KeyMap as KeyMap
19-
#endif
2017
import qualified Data.ByteString.Builder as B
2118
import qualified Data.ByteString.Char8 as BC
2219
import qualified Data.Foldable as F
23-
#if !MIN_VERSION_aeson(2,0,0)
24-
import qualified Data.HashMap.Strict as HM
25-
#endif
2620
import qualified Data.IntMap as IntMap
2721
import Data.List.Extra (groupSortOn)
2822
import qualified Data.List.NonEmpty as NonEmpty
@@ -185,20 +179,12 @@ renderStackYaml p ignoredPackages dupPackages =
185179
B.byteString headerHelp
186180
<> B.byteString "\n\n"
187181
<> F.foldMap (goComment o) comments
188-
#if MIN_VERSION_aeson(2,0,0)
189182
<> goOthers (o `KeyMap.difference` KeyMap.fromList comments)
190-
#else
191-
<> goOthers (o `HM.difference` HM.fromList comments)
192-
#endif
193183
<> B.byteString footerHelp
194184
<> "\n"
195185

196186
goComment o (name, comment) =
197-
#if MIN_VERSION_aeson(2,0,0)
198187
case (convert <$> KeyMap.lookup name o) <|> nonPresentValue name of
199-
#else
200-
case (convert <$> HM.lookup name o) <|> nonPresentValue name of
201-
#endif
202188
Nothing -> assert (name == "user-message") mempty
203189
Just v ->
204190
B.byteString comment <>
@@ -242,11 +228,7 @@ renderStackYaml p ignoredPackages dupPackages =
242228
| otherwise = ""
243229

244230
goOthers o
245-
#if MIN_VERSION_aeson(2,0,0)
246231
| KeyMap.null o = mempty
247-
#else
248-
| HM.null o = mempty
249-
#endif
250232
| otherwise = assert False $ B.byteString $ Yaml.encode o
251233

252234
-- Per Section Help

src/Stack/New.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE ConstraintKinds #-}
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE DeriveDataTypeable #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE OverloadedStrings #-}
@@ -19,9 +18,7 @@ module Stack.New
1918
import Stack.Prelude
2019
import Control.Monad.Trans.Writer.Strict
2120
import Data.Aeson as A
22-
#if MIN_VERSION_aeson(2,0,0)
2321
import qualified Data.Aeson.KeyMap as KeyMap
24-
#endif
2522
import qualified Data.ByteString.Base64 as B64
2623
import Data.ByteString.Builder (lazyByteString)
2724
import qualified Data.ByteString.Lazy as LB
@@ -44,9 +41,6 @@ import Stack.Constants
4441
import Stack.Constants.Config
4542
import Stack.Types.Config
4643
import Stack.Types.TemplateName
47-
#if !MIN_VERSION_aeson(2,0,0)
48-
import qualified RIO.HashMap as HM
49-
#endif
5044
import RIO.Process
5145
import qualified Text.Mustache as Mustache
5246
import qualified Text.Mustache.Render as Mustache
@@ -215,11 +209,7 @@ settingsFromRepoTemplatePath (RepoTemplatePath Github user name) =
215209
, tplExtract = \bs -> do
216210
decodedJson <- eitherDecode (LB.fromStrict bs)
217211
case decodedJson of
218-
#if MIN_VERSION_aeson(2,0,0)
219212
Object o | Just (String content) <- KeyMap.lookup "content" o -> do
220-
#else
221-
Object o | Just (String content) <- HM.lookup "content" o -> do
222-
#endif
223213
let noNewlines = T.filter (/= '\n')
224214
bsContent <- B64.decode $ T.encodeUtf8 (noNewlines content)
225215
mapLeft show $ decodeUtf8' bsContent

src/Stack/Options/Completion.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
2-
{-# LANGUAGE CPP #-}
32
{-# LANGUAGE OverloadedStrings #-}
43
{-# LANGUAGE TupleSections #-}
54

@@ -17,9 +16,6 @@ import Data.Maybe
1716
import qualified Data.Set as Set
1817
import qualified Data.Text as T
1918
import qualified Distribution.PackageDescription as C
20-
#if !MIN_VERSION_Cabal(3,4,0)
21-
import qualified Distribution.Types.UnqualComponentName as C
22-
#endif
2319
import Options.Applicative
2420
import Options.Applicative.Builder.Extra
2521
import Stack.Constants (ghcShowOptionsOutput)

0 commit comments

Comments
 (0)