Skip to content

Commit dccd1f8

Browse files
committed
Support building with GHC 8.4
1 parent 53df9e0 commit dccd1f8

File tree

15 files changed

+100
-36
lines changed

15 files changed

+100
-36
lines changed

src/Data/Aeson/Extended.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ data WarningParserMonoid = WarningParserMonoid
142142
{ wpmExpectedFields :: !(Set Text)
143143
, wpmWarnings :: [JSONWarning]
144144
} deriving Generic
145+
instance Semigroup WarningParserMonoid where
146+
(<>) = mappenddefault
145147
instance Monoid WarningParserMonoid where
146148
mempty = memptydefault
147-
mappend = mappenddefault
149+
mappend = (<>)
148150
instance IsString WarningParserMonoid where
149151
fromString s = mempty { wpmWarnings = [fromString s] }
150152

@@ -153,9 +155,11 @@ data WithJSONWarnings a = WithJSONWarnings a [JSONWarning]
153155
deriving (Eq, Generic, Show)
154156
instance Functor WithJSONWarnings where
155157
fmap f (WithJSONWarnings x w) = WithJSONWarnings (f x) w
158+
instance Monoid a => Semigroup (WithJSONWarnings a) where
159+
(<>) = mappenddefault
156160
instance Monoid a => Monoid (WithJSONWarnings a) where
157161
mempty = memptydefault
158-
mappend = mappenddefault
162+
mappend = (<>)
159163

160164
-- | Warning output from 'WarningParser'.
161165
data JSONWarning = JSONUnrecognizedFields String [Text]

src/Stack/Build/ConstructPlan.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ data W = W
114114
, wParents :: !ParentMap
115115
-- ^ Which packages a given package depends on, along with the package's version
116116
} deriving Generic
117+
instance Semigroup W where
118+
(<>) = mappenddefault
117119
instance Monoid W where
118120
mempty = memptydefault
119-
mappend = mappenddefault
121+
mappend = (<>)
120122

121123
type M = RWST -- TODO replace with more efficient WS stack on top of StackT
122124
Ctx
@@ -1148,8 +1150,11 @@ extendDepsPath ident dp = DepsPath
11481150
newtype MonoidMap k a = MonoidMap (Map k a)
11491151
deriving (Eq, Ord, Read, Show, Generic, Functor)
11501152

1151-
instance (Ord k, Monoid a) => Monoid (MonoidMap k a) where
1152-
mappend (MonoidMap mp1) (MonoidMap mp2) = MonoidMap (M.unionWith mappend mp1 mp2)
1153+
instance (Ord k, Semigroup a) => Semigroup (MonoidMap k a) where
1154+
MonoidMap mp1 <> MonoidMap mp2 = MonoidMap (M.unionWith (<>) mp1 mp2)
1155+
1156+
instance (Ord k, Monoid a, Semigroup a) => Monoid (MonoidMap k a) where
1157+
mappend = (<>)
11531158
mempty = MonoidMap mempty
11541159

11551160
-- Switch this to 'True' to enable some debugging putStrLn in this module

src/Stack/Ls.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE NoImplicitPrelude #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-# LANGUAGE RecordWildCards #-}
34
{-# LANGUAGE ScopedTypeVariables #-}
@@ -14,10 +15,10 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
1415
import Control.Monad.Reader (MonadReader)
1516
import Control.Monad (when)
1617
import Data.Aeson
18+
import Stack.Prelude
1719
import Stack.Types.Runner
1820
import qualified Data.Aeson.Types as A
1921
import qualified Data.List as L
20-
import Data.Monoid
2122
import Data.Text hiding (pack, intercalate)
2223
import qualified Data.Text as T
2324
import qualified Data.Text.IO as T

src/Stack/PackageIndex.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{-# LANGUAGE NoImplicitPrelude #-}
1+
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE BangPatterns #-}
3+
{-# LANGUAGE CPP #-}
34
{-# LANGUAGE ConstraintKinds #-}
45
{-# LANGUAGE DataKinds #-}
56
{-# LANGUAGE DeriveDataTypeable #-}
@@ -400,7 +401,11 @@ getPackageCaches = do
400401
result <- liftM mconcat $ forM (clIndices cl) $ \index -> do
401402
fp <- configPackageIndexCache (indexName index)
402403
PackageCache pis <-
404+
#if MIN_VERSION_template_haskell(2,13,0)
405+
$(versionedDecodeOrLoad (storeVersionConfig "pkg-v5" "LLL6OCcimOqRm3r0JmsSlLHcaLE="
406+
#else
403407
$(versionedDecodeOrLoad (storeVersionConfig "pkg-v5" "A607WaDwhg5VVvZTxNgU9g52DO8="
408+
#endif
404409
:: VersionConfig (PackageCache ())))
405410
fp
406411
(populateCache index)

src/Stack/Setup/Installed.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ data ExtraDirs = ExtraDirs
176176
, edInclude :: ![Path Abs Dir]
177177
, edLib :: ![Path Abs Dir]
178178
} deriving (Show, Generic)
179+
instance Semigroup ExtraDirs where
180+
(<>) = mappenddefault
179181
instance Monoid ExtraDirs where
180182
mempty = memptydefault
181-
mappend = mappenddefault
183+
mappend = (<>)
182184

183185
installDir :: (MonadReader env m, MonadThrow m)
184186
=> Path Abs Dir

src/Stack/Types/BuildPlan.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,15 @@ data DepInfo = DepInfo
363363
instance Store DepInfo
364364
instance NFData DepInfo
365365

366-
instance Monoid DepInfo where
367-
mempty = DepInfo mempty (fromVersionRange C.anyVersion)
368-
DepInfo a x `mappend` DepInfo b y = DepInfo
366+
instance Semigroup DepInfo where
367+
DepInfo a x <> DepInfo b y = DepInfo
369368
(mappend a b)
370369
(intersectVersionIntervals x y)
371370

371+
instance Monoid DepInfo where
372+
mempty = DepInfo mempty (fromVersionRange C.anyVersion)
373+
mappend = (<>)
374+
372375
data Component = CompLibrary
373376
| CompExecutable
374377
| CompTestSuite
@@ -390,10 +393,13 @@ newtype ModuleInfo = ModuleInfo
390393
instance Store ModuleInfo
391394
instance NFData ModuleInfo
392395

396+
instance Semigroup ModuleInfo where
397+
ModuleInfo x <> ModuleInfo y =
398+
ModuleInfo (Map.unionWith Set.union x y)
399+
393400
instance Monoid ModuleInfo where
394401
mempty = ModuleInfo mempty
395-
mappend (ModuleInfo x) (ModuleInfo y) =
396-
ModuleInfo (Map.unionWith Set.union x y)
402+
mappend = (<>)
397403

398404
moduleInfoVC :: VersionConfig ModuleInfo
399405
moduleInfoVC = storeVersionConfig "mi-v2" "8ImAfrwMVmqoSoEpt85pLvFeV3s="

src/Stack/Types/Config.hs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,12 @@ data GlobalOptsMonoid = GlobalOptsMonoid
459459
, globalMonoidStackYaml :: !(First FilePath) -- ^ Override project stack.yaml
460460
} deriving (Show, Generic)
461461

462+
instance Semigroup GlobalOptsMonoid where
463+
(<>) = mappenddefault
464+
462465
instance Monoid GlobalOptsMonoid where
463466
mempty = memptydefault
464-
mappend = mappenddefault
467+
mappend = (<>)
465468

466469
-- | Default logging level should be something useful but not crazy.
467470
defaultLogLevel :: LogLevel
@@ -771,9 +774,12 @@ data ConfigMonoid =
771774
}
772775
deriving (Show, Generic)
773776

777+
instance Semigroup ConfigMonoid where
778+
(<>) = mappenddefault
779+
774780
instance Monoid ConfigMonoid where
775781
mempty = memptydefault
776-
mappend = mappenddefault
782+
mappend = (<>)
777783

778784
parseConfigMonoid :: Path Abs Dir -> Value -> Yaml.Parser (WithJSONWarnings ConfigMonoid)
779785
parseConfigMonoid = withObjectWarnings "ConfigMonoid" . parseConfigMonoidObject
@@ -1676,6 +1682,16 @@ instance FromJSON (WithJSONWarnings SetupInfo) where
16761682

16771683
-- | For @siGHCs@ and @siGHCJSs@ fields maps are deeply merged.
16781684
-- For all fields the values from the last @SetupInfo@ win.
1685+
instance Semigroup SetupInfo where
1686+
l <> r =
1687+
SetupInfo
1688+
{ siSevenzExe = siSevenzExe r <|> siSevenzExe l
1689+
, siSevenzDll = siSevenzDll r <|> siSevenzDll l
1690+
, siMsys2 = siMsys2 r <> siMsys2 l
1691+
, siGHCs = Map.unionWith (<>) (siGHCs r) (siGHCs l)
1692+
, siGHCJSs = Map.unionWith (<>) (siGHCJSs r) (siGHCJSs l)
1693+
, siStack = Map.unionWith (<>) (siStack l) (siStack r) }
1694+
16791695
instance Monoid SetupInfo where
16801696
mempty =
16811697
SetupInfo
@@ -1686,14 +1702,7 @@ instance Monoid SetupInfo where
16861702
, siGHCJSs = Map.empty
16871703
, siStack = Map.empty
16881704
}
1689-
mappend l r =
1690-
SetupInfo
1691-
{ siSevenzExe = siSevenzExe r <|> siSevenzExe l
1692-
, siSevenzDll = siSevenzDll r <|> siSevenzDll l
1693-
, siMsys2 = siMsys2 r <> siMsys2 l
1694-
, siGHCs = Map.unionWith (<>) (siGHCs r) (siGHCs l)
1695-
, siGHCJSs = Map.unionWith (<>) (siGHCJSs r) (siGHCJSs l)
1696-
, siStack = Map.unionWith (<>) (siStack l) (siStack r) }
1705+
mappend = (<>)
16971706

16981707
-- | Remote or inline 'SetupInfo'
16991708
data SetupInfoLocation

src/Stack/Types/Config/Build.hs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,12 @@ buildMonoidSplitObjsName = "split-objs"
290290
buildMonoidSkipComponentsName :: Text
291291
buildMonoidSkipComponentsName = "skip-components"
292292

293+
instance Semigroup BuildOptsMonoid where
294+
(<>) = mappenddefault
295+
293296
instance Monoid BuildOptsMonoid where
294297
mempty = memptydefault
295-
mappend = mappenddefault
298+
mappend = (<>)
296299

297300
-- | Which subset of packages to build
298301
data BuildSubset
@@ -347,9 +350,12 @@ toMonoidCoverageArgName = "coverage"
347350
toMonoidDisableRunArgName :: Text
348351
toMonoidDisableRunArgName = "no-run-tests"
349352

353+
instance Semigroup TestOptsMonoid where
354+
(<>) = mappenddefault
355+
350356
instance Monoid TestOptsMonoid where
351357
mempty = memptydefault
352-
mappend = mappenddefault
358+
mappend = (<>)
353359

354360

355361

@@ -370,9 +376,12 @@ instance FromJSON (WithJSONWarnings HaddockOptsMonoid) where
370376
(\o -> do hoMonoidAdditionalArgs <- o ..:? hoMonoidAdditionalArgsName ..!= []
371377
return HaddockOptsMonoid{..})
372378

379+
instance Semigroup HaddockOptsMonoid where
380+
(<>) = mappenddefault
381+
373382
instance Monoid HaddockOptsMonoid where
374383
mempty = memptydefault
375-
mappend = mappenddefault
384+
mappend = (<>)
376385

377386
hoMonoidAdditionalArgsName :: Text
378387
hoMonoidAdditionalArgsName = "haddock-args"
@@ -409,9 +418,12 @@ beoMonoidAdditionalArgsArgName = "benchmark-arguments"
409418
beoMonoidDisableRunArgName :: Text
410419
beoMonoidDisableRunArgName = "no-run-benchmarks"
411420

421+
instance Semigroup BenchmarkOptsMonoid where
422+
(<>) = mappenddefault
423+
412424
instance Monoid BenchmarkOptsMonoid where
413425
mempty = memptydefault
414-
mappend = mappenddefault
426+
mappend = (<>)
415427

416428
data FileWatchOpts
417429
= NoFileWatch

src/Stack/Types/Docker.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ instance FromJSON (WithJSONWarnings DockerOptsMonoid) where
131131
..!= VersionRangeJSON anyVersion)
132132
return DockerOptsMonoid{..})
133133

134+
-- | Left-biased combine Docker options
135+
instance Semigroup DockerOptsMonoid where
136+
(<>) = mappenddefault
137+
134138
-- | Left-biased combine Docker options
135139
instance Monoid DockerOptsMonoid where
136140
mempty = memptydefault
137-
mappend = mappenddefault
141+
mappend = (<>)
138142

139143
-- | Where to get the `stack` executable to run in Docker containers
140144
data DockerStackExe

src/Stack/Types/Image.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ instance FromJSON (WithJSONWarnings ImageOptsMonoid) where
5151
{ ..
5252
})
5353

54+
instance Semigroup ImageOptsMonoid where
55+
(<>) = mappenddefault
56+
5457
instance Monoid ImageOptsMonoid where
5558
mempty = memptydefault
56-
mappend = mappenddefault
59+
mappend = (<>)
5760

5861
instance FromJSON (WithJSONWarnings ImageDockerOpts) where
5962
parseJSON = withObjectWarnings

0 commit comments

Comments
 (0)