Skip to content

Commit fecf2bf

Browse files
authored
Merge pull request #5945 from IntersectMBO/erikd/ghc-9.10
Make it build with ghc-9.10
2 parents 4b8f3d2 + 2aa3ad6 commit fecf2bf

File tree

10 files changed

+61
-41
lines changed

10 files changed

+61
-41
lines changed

.github/workflows/haskell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
# If you edit these versions, make sure the version in the lonely macos-latest job below is updated accordingly
3939
# TODO add 9.8 again to the versions list when GHC-9.8 gets released with stm > 2.5.2,
4040
# see https://github.com/haskell/stm/issues/76
41-
ghc: ["9.6"]
41+
ghc: ["9.6", "9.10"]
4242
cabal: ["3.12"]
4343
sys:
4444
- { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
@@ -49,7 +49,7 @@ jobs:
4949
- cabal: "3.12"
5050
ghc: "9.6"
5151
sys:
52-
os: macos-latest
52+
os: macos-13
5353
shell: bash
5454
defaults:
5555
run:

bench/locli/locli.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ library
114114
, filepath
115115
, fingertree
116116
, hashable
117-
, ghc
118117
, gnuplot
119118
, iohk-monitoring
120119
, optparse-applicative-fork

bench/locli/src/Cardano/Util.hs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE DeriveAnyClass #-}
32
{-# LANGUAGE DeriveFunctor #-}
43
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
@@ -7,7 +6,6 @@
76
{- HLINT ignore "Use list literal pattern" -}
87
module Cardano.Util
98
( module Prelude
10-
, module Util
119
, module Data.Aeson
1210
, module Data.IntervalMap.FingerTree
1311
, module Data.SOP
@@ -30,20 +28,6 @@ import Prelude (String, error, head, last)
3028
import Text.Show qualified as Show (Show(..))
3129
import Cardano.Prelude
3230

33-
#if __GLASGOW_HASKELL__ < 902
34-
-- This is a GHC module ...
35-
import Util hiding (fst3, snd3)
36-
#elif __GLASGOW_HASKELL__ < 906
37-
-- that moved for the ghc-9.2 release.
38-
import GHC.Utils.Misc as Util
39-
hiding (fst3, snd3, third3, uncurry3, firstM, secondM)
40-
#else
41-
-- that moved again for the ghc-9.6 release.
42-
-- Taking an internal module of GHC and re-exporting it is an incredibly dumb idea.
43-
import GHC.Utils.Misc as Util
44-
hiding (fst3, snd3, third3, uncurry3)
45-
#endif
46-
4731
import Data.Aeson (FromJSON (..), ToJSON (..), Object, Value (..), (.:), (.:?), (.!=), withObject, object)
4832
import Data.Aeson qualified as AE
4933
import Control.Arrow ((&&&), (***))
@@ -254,3 +238,26 @@ toRUTCTime = RUTCTime . unsafeUTCToNominal
254238

255239
fromRUTCTime :: RUTCTime -> UTCTime
256240
fromRUTCTime = unsafeNominalToUTC . unRUTCTime
241+
242+
-- -------------------------------------------------------------------------------------------------
243+
-- Importing from GHC.* is a bad idea, because that library changes from compiler release to
244+
-- compiler release and adds dependency constraints that are too tight.
245+
-- Both of these issues makes supporting multiple GHC versions significantly more difficult
246+
-- than it should be.
247+
-- Cargo cult these two functions instead.
248+
249+
-- Stolen from GHC.Utils.Misc
250+
count :: (a -> Bool) -> [a] -> Int
251+
count p = go 0
252+
where go !n [] = n
253+
go !n (x:xs) | p x = go (n+1) xs
254+
| otherwise = go n xs
255+
256+
-- Stolen from GHC.Utils.Misc
257+
mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c])
258+
mapAndUnzip _ [] = ([], [])
259+
mapAndUnzip f (x:xs)
260+
= let (r1, r2) = f x
261+
(rs1, rs2) = mapAndUnzip f xs
262+
in
263+
(r1:rs1, r2:rs2)

bench/locli/src/Data/DataDomain.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ where
1010
import Cardano.Prelude
1111

1212
import Witherable qualified as Wither
13-
import Data.List.NonEmpty qualified as NE
1413

1514
import Cardano.Util
1615
import Data.CDF
@@ -61,7 +60,7 @@ traverseDataDomain' ::
6160
traverseDataDomain' f xs =
6261
DataDomain
6362
<$> (Interval <$> f (xs <&> low . ddRaw) <*> f (xs <&> high . ddRaw))
64-
<*> (let lohis = NE.unzip $ (fmap (low &&& high) . ddFiltered) `Wither.mapMaybe` xs
63+
<*> (let lohis = neUnzip $ (fmap (low &&& high) . ddFiltered) `Wither.mapMaybe` xs
6564
in Just <$> (Interval <$> f (fst lohis) <*> f (snd lohis)))
6665
<*> f (xs <&> ddRawCount)
6766
<*> f (xs <&> ddFilteredCount)
@@ -97,3 +96,12 @@ intersectDataDomains xs =
9796
, ddRawCount = I $ sum $ xs <&> unI . ddRawCount
9897
, ddFilteredCount = I $ sum $ xs <&> unI . ddFilteredCount
9998
}
99+
100+
-- In [email protected] the Data.List.NonEmpty.unzip is deprecated and suggests that
101+
-- Data.Function.unzip should be used instead,but base versions earlier than
102+
-- 4.20 do not have that.
103+
-- Neatest solution is to cargo cult it here and switch to Data.Function.unzip
104+
-- later.
105+
neUnzip :: Functor f => f (a,b) -> (f a, f b)
106+
neUnzip xs = (fst <$> xs, snd <$> xs)
107+

bench/tx-generator/src/Cardano/TxGenerator/PureExample.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Control.Monad (foldM)
2121
import Control.Monad.Trans.State.Strict
2222
import Data.Aeson (eitherDecodeFileStrict')
2323
import Data.Either (fromRight)
24-
import Data.List (foldl')
24+
import Data.List as List (foldl')
2525
import Data.String (fromString)
2626
import System.Exit (die)
2727

@@ -121,7 +121,7 @@ generateTx TxEnvironment{..}
121121
return $ Right funds
122122

123123
addNewOutputFunds :: [Fund] -> Generator ()
124-
addNewOutputFunds = put . foldl' insertFund emptyFundQueue
124+
addNewOutputFunds = put . List.foldl' insertFund emptyFundQueue
125125

126126
computeOutputValues :: [L.Coin] -> [L.Coin]
127127
computeOutputValues = inputsToOutputsWithFee fee numOfOutputs
@@ -147,7 +147,7 @@ generateTxPure ::
147147
generateTxPure TxEnvironment{..} inQueue
148148
= do
149149
(tx, txId) <- generator inputs outputs
150-
let outQueue = foldl' insertFund emptyFundQueue (toFunds txId)
150+
let outQueue = List.foldl' insertFund emptyFundQueue (toFunds txId)
151151
pure (tx, outQueue)
152152
where
153153
inputs = toList inQueue

cabal.project

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repository cardano-haskell-packages
1313
-- See CONTRIBUTING for information about these, including some Nix commands
1414
-- you need to run if you change them
1515
index-state:
16-
, hackage.haskell.org 2024-08-15T08:53:32Z
17-
, cardano-haskell-packages 2024-08-15T10:40:33Z
16+
, hackage.haskell.org 2024-08-20T21:35:22Z
17+
, cardano-haskell-packages 2024-08-18T22:35:14Z
1818

1919
packages:
2020
cardano-node
@@ -58,10 +58,16 @@ package plutus-scripts-bench
5858
haddock-options: "--optghc=-fplugin-opt PlutusTx.Plugin:defer-errors"
5959

6060
constraints:
61-
wai-extra < 3.1.15,
61+
, wai-extra < 3.1.15
6262

6363
allow-newer:
64-
katip:Win32
64+
, katip:Win32
65+
66+
-- https://github.com/L0neGamer/ekg-json/pull/21
67+
-- https://github.com/L0neGamer/ekg/issues/94
68+
, ekg:base
69+
, ekg:filepath
70+
, ekg-json:base
6571

6672
-- IMPORTANT
6773
-- Do NOT add more source-repository-package stanzas here unless they are strictly

cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ import Ouroboros.Network.TxSubmission.Outbound
7171
import Control.Monad.Class.MonadTime.SI (Time (..))
7272
import Data.Aeson (ToJSON, Value (Number, String), toJSON, (.=))
7373
import qualified Data.Aeson as Aeson
74-
import Data.Foldable (Foldable (..))
7574
import Data.Int (Int64)
7675
import Data.IntPSQ (IntPSQ)
7776
import qualified Data.IntPSQ as Pq
77+
import qualified Data.List as List
7878
import qualified Data.Text as Text
7979
import Data.Time (DiffTime, NominalDiffTime)
8080
import Data.Word (Word32, Word64)
@@ -648,7 +648,7 @@ instance (LogFormatting peer, Show peer) =>
648648
forMachine _ xs = mconcat
649649
[ "kind" .= String "PeersFetch"
650650
, "peers" .= toJSON
651-
(foldl' (\acc x -> forMachine DDetailed x : acc) [] xs) ]
651+
(List.foldl' (\acc x -> forMachine DDetailed x : acc) [] xs) ]
652652

653653
asMetrics peers = [IntM "BlockFetch.ConnectedPeers" (fromIntegral (length peers))]
654654

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Control.Exception (throwIO)
1818
import qualified Data.Aeson as AE
1919
import Data.ByteString (ByteString)
2020
import qualified Data.ByteString.Char8 as BS
21-
import Data.List (foldl')
21+
import Data.List as List (foldl')
2222
import qualified Data.Map.Strict as Map
2323
import Data.Maybe (catMaybes, listToMaybe)
2424
import Data.Text (Text, intercalate, split)
@@ -122,7 +122,7 @@ parseRepresentation bs = transform (decodeEither' bs)
122122
transform (Right rl) = Right $ transform' emptyTraceConfig rl
123123
transform' :: TraceConfig -> ConfigRepresentation -> TraceConfig
124124
transform' TraceConfig {tcOptions=to'} cr =
125-
let to'' = foldl' (\ tci (nsp, opts') ->
125+
let to'' = List.foldl' (\ tci (nsp, opts') ->
126126
let ns' = split (=='.') nsp
127127
ns'' = if ns' == [""] then [] else ns'
128128
ns''' = case ns'' of
@@ -164,7 +164,7 @@ configToRepresentation traceConfig =
164164
toOptionRepresentation :: Map.Map [Text] [ConfigOption]
165165
-> Map.Map Text ConfigOptionRep
166166
toOptionRepresentation internalOptMap =
167-
foldl' conversion Map.empty (Map.toList internalOptMap)
167+
List.foldl' conversion Map.empty (Map.toList internalOptMap)
168168

169169
conversion :: Map.Map Text ConfigOptionRep
170170
-> ([Text],[ConfigOption])

trace-dispatcher/src/Cardano/Logging/Consistency.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Cardano.Logging.Consistency (
77
import Cardano.Logging.ConfigurationParser
88
import Cardano.Logging.Types
99

10-
import Data.Foldable (foldl')
10+
import Data.Foldable as Foldable (foldl')
1111
import qualified Data.Map.Strict as Map
1212
import Data.Maybe (mapMaybe)
1313
import qualified Data.Text as T
@@ -69,7 +69,7 @@ checkNamespace nsLookup ns = go nsLookup ns
6969
-- Warns as well if namespaces in all namespaces are ending in the
7070
-- middle of another namespace.
7171
asNSLookup :: [[T.Text]] -> (NSLookup, NSWarnings)
72-
asNSLookup = foldl' (fillLookup []) (NSLookup Map.empty, [])
72+
asNSLookup = Foldable.foldl' (fillLookup []) (NSLookup Map.empty, [])
7373
where
7474
fillLookup :: [T.Text] -> (NSLookup, NSWarnings) -> [T.Text] -> (NSLookup, NSWarnings)
7575
fillLookup _nsFull (NSLookup nsl, nsw) [] = (NSLookup nsl, nsw)

0 commit comments

Comments
 (0)