Skip to content

Commit 67b792f

Browse files
committed
Make it build with ghc-9.10
1 parent ee232fb commit 67b792f

File tree

30 files changed

+96
-66
lines changed

30 files changed

+96
-66
lines changed

cabal.project

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ repository cardano-haskell-packages
1414
-- update either of these.
1515
index-state:
1616
-- Bump this if you need newer packages from Hackage
17-
, hackage.haskell.org 2024-06-23T23:01:13Z
17+
, hackage.haskell.org 2024-07-23T00:03:37Z
1818
-- Bump this if you need newer packages from CHaP
19-
, cardano-haskell-packages 2024-07-02T04:22:05Z
19+
, cardano-haskell-packages 2024-07-24T06:25:44Z
2020

2121
packages:
2222
ouroboros-consensus
@@ -38,3 +38,18 @@ import: ./asserts.cabal
3838
if(os(windows))
3939
constraints:
4040
bitvec -simd
41+
42+
if impl(ghc >= 9.10)
43+
allow-newer:
44+
-- All these cardano-ledger packages have been fixed on master but not
45+
-- yet released to CHaP and according to the team will not be released
46+
-- until after the Chang hardfork.
47+
, cardano-ledger-alonzo:plutus-ledger-api
48+
, cardano-ledger-alonzo-test:plutus-ledger-api
49+
, cardano-ledger-babbage:plutus-ledger-api
50+
, cardano-ledger-binary:plutus-ledger-api
51+
, cardano-ledger-conway:plutus-ledger-api
52+
53+
constraints:
54+
-- Earlier versions do not compile with ghc-9.10
55+
, plutus-ledger-api ^>=1.31

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ library
127127
Ouroboros.Consensus.Shelley.Ledger.Query.PParamsLegacyEncoder
128128

129129
build-depends:
130-
base >=4.14 && <4.20,
130+
base >=4.14 && <4.21,
131131
base-deriving-via,
132132
bytestring >=0.10 && <0.13,
133133
cardano-binary,
@@ -190,7 +190,7 @@ library unstable-byronspec
190190
Ouroboros.Consensus.ByronSpec.Ledger.Rules
191191

192192
build-depends:
193-
base >=4.14 && <4.20,
193+
base >=4.14 && <4.21,
194194
bimap >=0.4 && <0.6,
195195
byron-spec-chain,
196196
byron-spec-ledger,
@@ -515,7 +515,7 @@ library unstable-cardano-tools
515515

516516
build-depends:
517517
aeson,
518-
base >=4.14 && <4.20,
518+
base >=4.14 && <4.21,
519519
base16-bytestring >=1.0,
520520
bytestring >=0.10 && <0.13,
521521
cardano-crypto,

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import qualified Cardano.Ledger.Shelley.BlockChain as SL (bBodySize)
1414
import qualified Cardano.Protocol.TPraos.BHeader as SL
1515
import Control.Exception
1616
import Control.Monad.Except
17-
import Data.List (foldl')
17+
import Data.List as List (foldl')
1818
import qualified Data.Sequence.Strict as Seq
1919
import Ouroboros.Consensus.Block
2020
import Ouroboros.Consensus.Config
@@ -98,5 +98,5 @@ forgeShelleyBlock
9898
= return ()
9999

100100
estimatedBodySize, actualBodySize :: Int
101-
estimatedBodySize = fromIntegral $ foldl' (+) 0 $ map (txInBlockSize . txForgetValidated) txs
101+
estimatedBodySize = fromIntegral $ List.foldl' (+) 0 $ map (txInBlockSize . txForgetValidated) txs
102102
actualBodySize = SL.bBodySize protocolVersion body

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Block/Shelley.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import qualified Cardano.Ledger.Shelley.API as SL
2929
import qualified Cardano.Ledger.Shelley.RewardUpdate as SL
3030
import Cardano.Tools.DBAnalyser.HasAnalysis
3131
import qualified Data.Aeson as Aeson
32-
import Data.Foldable (foldl', toList)
32+
import Data.Foldable as Foldable (foldl', toList)
3333
import qualified Data.Map.Strict as Map
3434
import Data.Maybe (catMaybes, maybeToList)
3535
import Data.Maybe.Strict
@@ -91,7 +91,7 @@ instance ( ShelleyCompatible proto era
9191
, decimal $ sum $ blockTxSizes blk
9292
]
9393
++
94-
[ decimal $ foldl' (\acc tx -> acc + f tx) 0 txs
94+
[ decimal $ Foldable.foldl' (\acc tx -> acc + f tx) 0 txs
9595
| f <- maybeToList txExUnitsSteps
9696
]
9797
where

ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ library
7777
Ouroboros.Consensus.Node.Run,
7878

7979
build-depends:
80-
base >=4.14 && <4.20,
80+
base >=4.14 && <4.21,
8181
bytestring >=0.10 && <0.13,
8282
cardano-slotting,
8383
cborg ^>=0.2.2,

ouroboros-consensus-diffusion/src/unstable-diffusion-testlib/Test/ThreadNet/Network.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ directedEdgeInner registry clock (version, blockVersion) (cfg, calcMessageDelay)
13611361
_ -> retry
13621362

13631363
flattenPairs :: forall a. NE.NonEmpty (a, a) -> NE.NonEmpty a
1364-
flattenPairs = uncurry (<>) . NE.unzip
1364+
flattenPairs = uncurry (<>) . neUnzip
13651365

13661366
neverReturns :: forall x void. String -> x -> void
13671367
neverReturns s !_ = error $ s <> " never returns!"
@@ -1721,3 +1721,12 @@ data TxGenFailure = TxGenFailure Int -- ^ how many times it failed
17211721
deriving (Show)
17221722

17231723
instance Exception TxGenFailure
1724+
1725+
-- In [email protected] the Data.List.NonEmpty.unzip is deprecated and suggests that
1726+
-- Data.Function.unzip should be used instead,but base versions earlier than
1727+
-- 4.20 do not have that.
1728+
-- Neatest solution is to cargo cult it here and switch to Data.Function.unzip
1729+
-- later.
1730+
neUnzip :: Functor f => f (a,b) -> (f a, f b)
1731+
neUnzip xs = (fst <$> xs, snd <$> xs)
1732+

ouroboros-consensus-diffusion/src/unstable-diffusion-testlib/Test/ThreadNet/Ref/PBFT.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module Test.ThreadNet.Ref.PBFT (
2727
import Control.Applicative ((<|>))
2828
import Control.Arrow ((&&&))
2929
import Control.Monad (guard)
30-
import Data.Foldable (foldl', toList)
30+
import Data.Foldable as Foldable (foldl', toList)
3131
import Data.Map.Strict (Map)
3232
import qualified Data.Map.Strict as Map
3333
import Data.Sequence (Seq)
@@ -609,7 +609,7 @@ nextLeader params State{nextSlot} = mkLeaderOf params nextSlot
609609
fillOut :: PBftParams -> NodeJoinPlan -> SlotNo -> NodeJoinPlan
610610
fillOut params (NodeJoinPlan m) s =
611611
NodeJoinPlan $
612-
foldl' (\acc i -> Map.insert i j acc) m $
612+
Foldable.foldl' (\acc i -> Map.insert i j acc) m $
613613
CoreNodeId <$> [i0 .. iN]
614614
where
615615
iN = oneN params - 1

ouroboros-consensus-diffusion/src/unstable-diffusion-testlib/Test/ThreadNet/Util/Expectations.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Test.ThreadNet.Util.Expectations (
55
, determineForkLength
66
) where
77

8-
import Data.Foldable (foldl')
8+
import Data.Foldable as Foldable (foldl')
99
import qualified Data.Map.Strict as Map
1010
import Data.Word (Word64)
1111
import Ouroboros.Consensus.Block
@@ -99,7 +99,7 @@ determineForkLength ::
9999
-> LeaderSchedule
100100
-> NumBlocks
101101
determineForkLength k (NodeJoinPlan joinPlan) (LeaderSchedule sched) =
102-
prj $ foldl' step initial (Map.toAscList sched)
102+
prj $ Foldable.foldl' step initial (Map.toAscList sched)
103103
where
104104
prj Acc{maxForkLength} = NumBlocks maxForkLength
105105

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Setup/GenChains.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Cardano.Slotting.Time (SlotLength, getSlotLength,
1515
slotLengthFromSec)
1616
import Control.Monad (replicateM)
1717
import qualified Control.Monad.Except as Exn
18-
import Data.List (foldl')
18+
import Data.List as List (foldl')
1919
import Data.Proxy (Proxy (..))
2020
import Data.Time.Clock (DiffTime, secondsToDiffTime)
2121
import qualified Data.Vector.Unboxed as Vector
@@ -137,7 +137,7 @@ genChainsWithExtraHonestPeers genNumExtraHonest genNumForks = do
137137
-- values carry no special meaning. Someone needs to think about what values
138138
-- would make for interesting tests.
139139
gtCSJParams = CSJParams $ fromIntegral scg,
140-
gtBlockTree = foldl' (flip BT.addBranch') (BT.mkTrunk goodChain) $ zipWith (genAdversarialFragment goodBlocks) [1..] alternativeChainSchemas,
140+
gtBlockTree = List.foldl' (flip BT.addBranch') (BT.mkTrunk goodChain) $ zipWith (genAdversarialFragment goodBlocks) [1..] alternativeChainSchemas,
141141
gtExtraHonestPeers,
142142
gtSchedule = ()
143143
}
@@ -158,7 +158,7 @@ genChainsWithExtraHonestPeers genNumExtraHonest genNumForks = do
158158

159159
mkTestBlocks :: [TestBlock] -> [S] -> Int -> [TestBlock]
160160
mkTestBlocks pre active forkNo =
161-
fst (foldl' folder ([], 0) active)
161+
fst (List.foldl' folder ([], 0) active)
162162
where
163163
folder (chain, inc) s | S.test S.notInverted s = (issue inc chain, 0)
164164
| otherwise = (chain, inc + 1)

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/PeerSimulator/StateDiagram.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Control.Monad.State.Strict (State, gets, modify', runState,
2727
state)
2828
import Control.Tracer (Tracer (Tracer), debugTracer, traceWith)
2929
import Data.Bifunctor (first)
30-
import Data.Foldable (foldl', foldr')
30+
import Data.Foldable as Foldable (foldl', foldr')
3131
import Data.List (find, intersperse, mapAccumL, sort, transpose)
3232
import Data.List.NonEmpty (NonEmpty ((:|)), nonEmpty, (<|))
3333
import qualified Data.List.NonEmpty as NonEmpty
@@ -416,7 +416,7 @@ commonRange branch segment = do
416416
pure (Range (slotInt l + (if overFork then 0 else 1)) (slotInt u + 1), overFork)
417417
where
418418
findLower preB preS =
419-
foldl' step Nothing (zip preB preS)
419+
Foldable.foldl' step Nothing (zip preB preS)
420420
step prev (b1, b2) | b1 == b2 = Just b1
421421
| otherwise = prev
422422

@@ -476,7 +476,7 @@ addTipPoint _ _ treeSlots = treeSlots
476476

477477
addPoints :: Map PeerId (NodeState TestBlock) -> TreeSlots -> TreeSlots
478478
addPoints peerPoints treeSlots =
479-
foldl' step treeSlots (Map.toList peerPoints)
479+
Foldable.foldl' step treeSlots (Map.toList peerPoints)
480480
where
481481
step z (pid, ap) = addTipPoint pid (nsTip ap) z
482482

@@ -619,7 +619,7 @@ slotWidth =
619619

620620
contiguous :: [(Int, Bool, a)] -> [[(Int, a)]]
621621
contiguous ((i0, _, a0) : rest) =
622-
result (foldl' step (pure (i0, a0), []) rest)
622+
result (Foldable.foldl' step (pure (i0, a0), []) rest)
623623
where
624624
result (cur, res) = reverse (reverse (toList cur) : res)
625625

@@ -791,7 +791,7 @@ renderSlotWidth ellipsisWidth = \case
791791

792792
breakLines :: RenderConfig -> [RenderSlot] -> [[RenderSlot]]
793793
breakLines RenderConfig {lineWidth, ellipsis} =
794-
result . foldl' step (0, [], [])
794+
result . Foldable.foldl' step (0, [], [])
795795
where
796796
result (_, cur, res) = reverse (reverse cur : res)
797797
step (w, cur, res) slot
@@ -851,7 +851,7 @@ peerSimStateDiagramWith config PeerSimState {pssBlockTree, pssSelection, pssCand
851851
treeCells $
852852
addPoints pssPoints $
853853
addForks $
854-
flip (foldl' addCandidateRange) (Map.toList pssCandidates) $
854+
flip (Foldable.foldl' addCandidateRange) (Map.toList pssCandidates) $
855855
addFragRange Selection pssSelection $
856856
initTree pssBlockTree
857857

0 commit comments

Comments
 (0)