Skip to content

Commit 1543b15

Browse files
authored
Merge pull request #1031 from haskell/cabal-3.4
GHC 9.0 and Cabal 3.4 (fix #1016)
2 parents 23626c2 + 33d7a09 commit 1543b15

File tree

32 files changed

+350
-613
lines changed

32 files changed

+350
-613
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
versions:
20+
- ghc: '9.0.2'
21+
cabal: '3.6'
2022
- ghc: '8.10.7'
2123
cabal: '3.6'
2224
- ghc: '8.8.4'

hackage-server.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ common defaults
113113
-- other dependencies shared by most components
114114
build-depends:
115115
, aeson ^>= 1.5
116-
, Cabal ^>= 3.2.1.0
116+
, Cabal ^>= 3.4.1.0
117117
, fail ^>= 4.9.0
118118
-- we use Control.Monad.Except, introduced in mtl-2.2.1
119119
, network >= 3 && < 3.2

src/Data/TarIndex.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ newtype PathComponentId = PathComponentId Int
6969

7070
type TarEntryOffset = Int
7171

72-
$(deriveSafeCopy 0 'base ''TarIndex)
7372
$(deriveSafeCopy 0 'base ''PathComponentId)
73+
$(deriveSafeCopy 0 'base ''TarIndex)
7474
$(deriveSafeCopy 0 'base ''TarIndexEntry)
7575

7676
instance MemSize TarIndex where

src/Distribution/Server/Features/BuildReports/BuildReport.hs

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, RecordWildCards,
2-
TemplateHaskell, TypeFamilies, FlexibleInstances, MultiParamTypeClasses,
3-
OverloadedStrings #-}
1+
{-# LANGUAGE ConstraintKinds #-}
2+
{-# LANGUAGE DeriveDataTypeable #-}
3+
{-# LANGUAGE FlexibleInstances #-}
4+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE MultiParamTypeClasses #-}
6+
{-# LANGUAGE OverloadedStrings #-}
7+
{-# LANGUAGE RecordWildCards #-}
8+
{-# LANGUAGE TemplateHaskell #-}
9+
{-# LANGUAGE TypeFamilies #-}
410
-----------------------------------------------------------------------------
511
-- |
612
-- Module : Distribution.Client.Reporting
@@ -52,14 +58,16 @@ import Distribution.CabalSpecVersion
5258
import Distribution.Pretty
5359
( Pretty(..), pretty, prettyShow )
5460
import qualified Text.PrettyPrint as Disp
55-
import Distribution.Parsec.Newtypes
61+
5662
import Distribution.Parsec
5763
( Parsec(..), PError(..), parsec )
5864
import qualified Distribution.Parsec as P
5965
import qualified Distribution.Compat.CharParsing as P
6066
import Distribution.FieldGrammar
6167
( FieldGrammar, parseFieldGrammar, prettyFieldGrammar, partitionFields
62-
, uniqueField, uniqueFieldAla, booleanFieldDef, monoidalFieldAla )
68+
, uniqueField, uniqueFieldAla, booleanFieldDef, monoidalFieldAla
69+
, List, alaList
70+
, VCat(..), FSep(..) )
6371
import Distribution.Fields.Parser
6472
( readFields )
6573
import Distribution.Fields.Pretty
@@ -83,6 +91,7 @@ import Text.StringTemplate.Classes
8391

8492
import Data.String (fromString)
8593
import Data.Aeson
94+
import Data.Functor.Identity (Identity)
8695
import Data.List
8796
( unfoldr, isInfixOf )
8897
import Data.List.NonEmpty (toList)
@@ -308,7 +317,21 @@ show = showFields (const []) . prettyFieldGrammar CabalSpecV2_4 fieldDescrs
308317
-- -----------------------------------------------------------------------------
309318
-- Description of the fields, for parsing/printing
310319

311-
fieldDescrs :: (Applicative (g BuildReport), FieldGrammar g) => g BuildReport BuildReport
320+
321+
fieldDescrs
322+
:: ( Applicative (g BuildReport), FieldGrammar c g
323+
, c (Identity Arch)
324+
, c (Identity CompilerId)
325+
, c (List FSep (Identity FlagAss1) FlagAss1)
326+
-- , c (Identity FlagAssignment)
327+
, c (Identity InstallOutcome)
328+
, c (Identity OS)
329+
, c (Identity Outcome)
330+
, c (Identity PackageIdentifier)
331+
, c (List VCat (Identity PackageIdentifier) PackageIdentifier)
332+
, c Time
333+
)
334+
=> g BuildReport BuildReport
312335
fieldDescrs =
313336
BuildReport
314337
<$> uniqueField "package" packageL
@@ -473,17 +496,6 @@ instance Pretty BuildStatus where
473496
pretty (BuildFailCnt a) = Disp.text "BuildFailCnt " Disp.<+> pretty a
474497
pretty BuildOK = Disp.text "BuildOK"
475498

476-
-------------------
477-
-- SafeCopy instances
478-
--
479-
480-
deriveSafeCopy 0 'base ''Outcome
481-
deriveSafeCopy 1 'extension ''InstallOutcome
482-
deriveSafeCopy 3 'extension ''BuildReport
483-
deriveSafeCopy 1 'base ''BuildStatus
484-
deriveSafeCopy 1 'base ''BooleanCovg
485-
deriveSafeCopy 1 'base ''BuildCovg
486-
487499

488500
-------------------
489501
-- Old SafeCopy versions
@@ -551,6 +563,8 @@ data InstallOutcome_v0
551563
| V0_InstallFailed
552564
| V0_InstallOk
553565

566+
deriveSafeCopy 0 'base ''Outcome
567+
554568
deriveSafeCopy 0 'base ''InstallOutcome_v0
555569
deriveSafeCopy 2 'extension ''BuildReport_v1
556570

@@ -636,3 +650,13 @@ instance Data.Aeson.FromJSON PkgDetails where
636650
parseVersion :: Maybe String -> Maybe Version
637651
parseVersion Nothing = Nothing
638652
parseVersion (Just k) = P.simpleParsec k
653+
654+
-------------------
655+
-- SafeCopy instances
656+
--
657+
658+
deriveSafeCopy 1 'extension ''InstallOutcome
659+
deriveSafeCopy 3 'extension ''BuildReport
660+
deriveSafeCopy 1 'base ''BuildStatus
661+
deriveSafeCopy 1 'base ''BooleanCovg
662+
deriveSafeCopy 1 'base ''BuildCovg

src/Distribution/Server/Features/BuildReports/BuildReports.hs

Lines changed: 67 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ lookupReport pkgid reportId buildReports = remCvg.Map.lookup reportId . reports
114114
lookupPackageReports :: PackageId -> BuildReports -> [(BuildReportId, (BuildReport, Maybe BuildLog))]
115115
lookupPackageReports pkgid buildReports = case Map.lookup pkgid (reportsIndex buildReports) of
116116
Nothing -> []
117-
Just rs -> map removeCovg $Map.toList (reports rs)
117+
Just rs -> map removeCovg $ Map.toList (reports rs)
118118
where
119119
removeCovg (brid,(brpt,blog,_)) = (brid,(brpt,blog))
120120

@@ -214,9 +214,32 @@ instance ToSElem BuildReportId where
214214
-- SafeCopy instances
215215
--
216216

217+
218+
newtype BuildReportId_v0 = BuildReportId_v0 Int
219+
deriving (Serialize, Enum, Eq, Ord)
220+
221+
instance SafeCopy BuildReportId_v0 where
222+
getCopy = contain get
223+
putCopy = contain . put
224+
225+
instance Migrate BuildReportId where
226+
type MigrateFrom BuildReportId = BuildReportId_v0
227+
migrate (BuildReportId_v0 bid) = BuildReportId bid
228+
217229
deriveSafeCopy 2 'extension ''BuildReportId
230+
231+
newtype BuildLog_v0 = BuildLog_v0 BlobStorage.BlobId_v0
232+
deriving Serialize
233+
234+
instance SafeCopy BuildLog_v0 where
235+
getCopy = contain get
236+
putCopy = contain . put
237+
238+
instance Migrate BuildLog where
239+
type MigrateFrom BuildLog = BuildLog_v0
240+
migrate (BuildLog_v0 bl) = BuildLog (migrate bl)
241+
218242
deriveSafeCopy 2 'extension ''BuildLog
219-
deriveSafeCopy 3 'extension ''BuildReports
220243

221244
-- note: if the set of report ids is [1, 2, 3], then nextReportId = 4
222245
-- after calling deleteReport for 3, the set is [1, 2] and nextReportId is still 4.
@@ -233,21 +256,16 @@ instance SafeCopy PkgBuildReports where
233256
then BuildReportId 1
234257
else incrementReportId (fst $ Map.findMax rs))
235258
f
236-
instance MemSize BuildReports where
237-
memSize (BuildReports a) = memSize1 a
238259

239260
instance MemSize PkgBuildReports where
240261
memSize (PkgBuildReports a b c) = memSize3 a b c
241262

242-
-------------------
243-
-- Old V2 SafeCopy versions
244-
--
263+
245264
data PkgBuildReports_v2 = PkgBuildReports_v2 {
246265
reports_v2 :: !(Map BuildReportId (BuildReport, Maybe BuildLog)),
247266
nextReportId_v2 :: !BuildReportId
248267
} deriving (Eq, Typeable, Show)
249268

250-
251269
instance SafeCopy PkgBuildReports_v2 where
252270
version = 2
253271
kind = extension
@@ -262,6 +280,33 @@ instance SafeCopy PkgBuildReports_v2 where
262280
instance MemSize PkgBuildReports_v2 where
263281
memSize (PkgBuildReports_v2 a b) = memSize2 a b
264282

283+
data PkgBuildReports_v0 = PkgBuildReports_v0
284+
!(Map BuildReportId_v0 (BuildReport_v0, Maybe BuildLog_v0))
285+
!BuildReportId_v0
286+
287+
instance SafeCopy PkgBuildReports_v0 where
288+
getCopy = contain get
289+
putCopy = contain . put
290+
291+
instance Serialize PkgBuildReports_v0 where
292+
put (PkgBuildReports_v0 listing _) = Serialize.put listing
293+
get = mkReports <$> Serialize.get
294+
where
295+
mkReports rs = PkgBuildReports_v0 rs
296+
(if Map.null rs
297+
then BuildReportId_v0 1
298+
else succ (fst $ Map.findMax rs))
299+
300+
instance Migrate PkgBuildReports_v2 where
301+
type MigrateFrom PkgBuildReports_v2 = PkgBuildReports_v0
302+
migrate (PkgBuildReports_v0 m n) =
303+
PkgBuildReports_v2 (migrateMap m) (migrate n)
304+
where
305+
migrateMap :: Map BuildReportId_v0 (BuildReport_v0, Maybe BuildLog_v0)
306+
-> Map BuildReportId (BuildReport, Maybe BuildLog)
307+
migrateMap = Map.mapKeys migrate
308+
. Map.map (\(br, l) -> (migrate (migrate br),
309+
fmap migrate l))
265310

266311
instance Migrate PkgBuildReports where
267312
type MigrateFrom PkgBuildReports = PkgBuildReports_v2
@@ -273,47 +318,6 @@ instance Migrate PkgBuildReports where
273318
migrateMap = Map.mapKeys (\x->x)
274319
. Map.map (\(br, l) -> (br, l, Nothing))
275320

276-
---
277-
278-
data BuildReports_v2 = BuildReports_v2 {
279-
reportsIndex_v2 :: !(Map.Map PackageId PkgBuildReports_v2)
280-
} deriving (Eq, Typeable, Show)
281-
282-
deriveSafeCopy 2 'extension ''BuildReports_v2
283-
284-
instance MemSize BuildReports_v2 where
285-
memSize (BuildReports_v2 a) = memSize1 a
286-
287-
instance Migrate BuildReports where
288-
type MigrateFrom BuildReports = BuildReports_v2
289-
migrate (BuildReports_v2 m) =
290-
BuildReports (Map.mapKeys (\x->x) $ Map.map migrate m)
291-
-------------------
292-
-- Old SafeCopy versions
293-
--
294-
295-
newtype BuildReportId_v0 = BuildReportId_v0 Int deriving (Serialize, Enum, Eq, Ord)
296-
instance SafeCopy BuildReportId_v0 where
297-
getCopy = contain get
298-
putCopy = contain . put
299-
300-
instance Migrate BuildReportId where
301-
type MigrateFrom BuildReportId = BuildReportId_v0
302-
migrate (BuildReportId_v0 bid) = BuildReportId bid
303-
304-
---
305-
306-
newtype BuildLog_v0 = BuildLog_v0 BlobStorage.BlobId_v0 deriving Serialize
307-
instance SafeCopy BuildLog_v0 where
308-
getCopy = contain get
309-
putCopy = contain . put
310-
311-
312-
instance Migrate BuildLog where
313-
type MigrateFrom BuildLog = BuildLog_v0
314-
migrate (BuildLog_v0 bl) = BuildLog (migrate bl)
315-
316-
---
317321

318322
data BuildReports_v0 = BuildReports_v0
319323
!(Map.Map PackageIdentifier_v0 PkgBuildReports_v0)
@@ -326,37 +330,26 @@ instance Serialize BuildReports_v0 where
326330
put (BuildReports_v0 index) = Serialize.put index
327331
get = BuildReports_v0 <$> Serialize.get
328332

333+
data BuildReports_v2 = BuildReports_v2
334+
{ reportsIndex_v2 :: !(Map.Map PackageId PkgBuildReports_v2)
335+
} deriving (Eq, Typeable, Show)
336+
329337
instance Migrate BuildReports_v2 where
330338
type MigrateFrom BuildReports_v2 = BuildReports_v0
331339
migrate (BuildReports_v0 m) =
332340
BuildReports_v2 (Map.mapKeys migrate $ Map.map migrate m)
333341

334-
---
342+
instance MemSize BuildReports_v2 where
343+
memSize (BuildReports_v2 a) = memSize1 a
335344

336-
data PkgBuildReports_v0 = PkgBuildReports_v0
337-
!(Map BuildReportId_v0 (BuildReport_v0, Maybe BuildLog_v0))
338-
!BuildReportId_v0
345+
deriveSafeCopy 2 'extension ''BuildReports_v2
339346

340-
instance SafeCopy PkgBuildReports_v0 where
341-
getCopy = contain get
342-
putCopy = contain . put
347+
instance Migrate BuildReports where
348+
type MigrateFrom BuildReports = BuildReports_v2
349+
migrate (BuildReports_v2 m) =
350+
BuildReports (Map.mapKeys id $ Map.map migrate m)
343351

344-
instance Serialize PkgBuildReports_v0 where
345-
put (PkgBuildReports_v0 listing _) = Serialize.put listing
346-
get = mkReports <$> Serialize.get
347-
where
348-
mkReports rs = PkgBuildReports_v0 rs
349-
(if Map.null rs
350-
then BuildReportId_v0 1
351-
else succ (fst $ Map.findMax rs))
352+
instance MemSize BuildReports where
353+
memSize (BuildReports a) = memSize1 a
352354

353-
instance Migrate PkgBuildReports_v2 where
354-
type MigrateFrom PkgBuildReports_v2 = PkgBuildReports_v0
355-
migrate (PkgBuildReports_v0 m n) =
356-
PkgBuildReports_v2 (migrateMap m) (migrate n)
357-
where
358-
migrateMap :: Map BuildReportId_v0 (BuildReport_v0, Maybe BuildLog_v0)
359-
-> Map BuildReportId (BuildReport, Maybe BuildLog)
360-
migrateMap = Map.mapKeys migrate
361-
. Map.map (\(br, l) -> (migrate (migrate br),
362-
fmap migrate l))
355+
deriveSafeCopy 3 'extension ''BuildReports

0 commit comments

Comments
 (0)