Skip to content

Commit 5c2458e

Browse files
Adding support for GHC-9.12 based on the alpha release
1 parent 11738bd commit 5c2458e

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

.github/workflows/haskell.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2", "9.10.1"]
25+
# TODO: Change "9.12.0.20241031" --> "9.12.1" after official release
26+
ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2", "9.10.1", "9.12.0.20241031"]
2627
cabal: ["3.10.2.1"]
2728
os: [ubuntu-latest, windows-latest, macOS-latest]
2829
cabal-flags: [""]
@@ -67,6 +68,8 @@ jobs:
6768
ghc-version: ${{ matrix.ghc }}
6869
cabal-version: ${{ matrix.cabal }}
6970
cabal-update: true
71+
# TODO: remove once 9.12.1 is officially released
72+
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
7073

7174
- name: Install liburing (on Linux)
7275
id: setup-liburing

cabal.project.debug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ if impl(ghc >=9.4.6 && <9.5 || >=9.6.3)
2525
ghc-options: -fcheck-prim-bounds
2626

2727
package fs-sim
28-
ghc-options: -fcheck-prim-bounds
28+
ghc-options: -fcheck-prim-bounds
29+

cabal.project.release

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ source-repository-package
2626
type: git
2727
location: https://github.com/well-typed/quickcheck-lockstep.git
2828
tag: 1852cf87a76dc48c71aa0d9fda3fdc7c8b965011
29+
30+
if impl(ghc >=9.12)
31+
allow-newer: base

lsm-tree.cabal

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build-type: Simple
1313
extra-doc-files: CHANGELOG.md
1414
extra-source-files: README.md
1515
tested-with:
16-
GHC ==8.10 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10
16+
GHC ==8.10 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10 || ==9.12
1717

1818
source-repository head
1919
type: git
@@ -166,7 +166,7 @@ library
166166
Database.LSMTree.Normal
167167

168168
build-depends:
169-
, base >=4.14 && <4.21
169+
, base >=4.14 && <4.22
170170
, bitvec ^>=1.1
171171
, bytestring ^>=0.11.4.0 || ^>=0.12.1.0
172172
, cborg ^>=0.2.10.0
@@ -311,7 +311,7 @@ library extras
311311
Database.LSMTree.Extras.UTxO
312312

313313
build-depends:
314-
, base >=4.14 && <4.21
314+
, base >=4.14 && <4.22
315315
, bitvec
316316
, bytestring
317317
, containers
@@ -640,7 +640,7 @@ test-suite kmerge-test
640640
hs-source-dirs: test
641641
main-is: kmerge-test.hs
642642
build-depends:
643-
, base >=4.14 && <4.21
643+
, base >=4.14 && <4.22
644644
, deepseq
645645
, heaps
646646
, lsm-tree:kmerge
@@ -659,7 +659,7 @@ benchmark kmerge-bench
659659
main-is: kmerge-test.hs
660660
cpp-options: -DKMERGE_BENCHMARKS
661661
build-depends:
662-
, base >=4.14 && <4.21
662+
, base >=4.14 && <4.22
663663
, deepseq
664664
, heaps
665665
, lsm-tree:kmerge
@@ -677,7 +677,7 @@ test-suite map-range-test
677677
hs-source-dirs: test
678678
main-is: map-range-test.hs
679679
build-depends:
680-
, base >=4.14 && <4.21
680+
, base >=4.14 && <4.22
681681
, bytestring
682682
, containers
683683
, lsm-tree
@@ -738,7 +738,7 @@ library blockio-api
738738
System.FS.BlockIO.Serial
739739

740740
build-depends:
741-
, base >=4.14 && <4.21
741+
, base >=4.14 && <4.22
742742
, deepseq ^>=1.4 || ^>=1.5
743743
, fs-api ^>=0.3
744744
, io-classes ^>=1.6 || ^>=1.7
@@ -775,7 +775,7 @@ test-suite blockio-api-test
775775
main-is: Main.hs
776776
build-depends:
777777
, async
778-
, base >=4.14 && <4.21
778+
, base >=4.14 && <4.22
779779
, bytestring
780780
, fs-api
781781
, lsm-tree:blockio-api
@@ -795,7 +795,7 @@ library blockio-sim
795795
hs-source-dirs: blockio-sim/src
796796
exposed-modules: System.FS.BlockIO.Sim
797797
build-depends:
798-
, base >=4.14 && <4.21
798+
, base >=4.14 && <4.22
799799
, bytestring
800800
, fs-api ^>=0.3
801801
, fs-sim ^>=0.3
@@ -810,7 +810,7 @@ test-suite blockio-sim-test
810810
hs-source-dirs: blockio-sim/test
811811
main-is: Main.hs
812812
build-depends:
813-
, base >=4.14 && <4.21
813+
, base >=4.14 && <4.22
814814
, fs-api
815815
, fs-sim
816816
, io-classes:strict-stm
@@ -839,7 +839,7 @@ library control
839839
Control.TempRegistry
840840

841841
build-depends:
842-
, base >=4.14 && <4.21
842+
, base >=4.14 && <4.22
843843
, containers ^>=0.6 || ^>=0.7
844844
, deepseq ^>=1.4 || ^>=1.5
845845
, io-classes ^>=1.6 || ^>=1.7

test/kmerge-test.hs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Test.Tasty.QuickCheck (testProperty, (===))
2929
import qualified KMerge.Heap as K.Heap
3030
import qualified KMerge.LoserTree as K.Tree
3131

32+
3233
-- tests and benchmarks for various k-way merge implementations.
3334
-- in short: loser tree is optimal in comparison counts performed,
3435
-- but mutable heap implementation has lower constant factors.
@@ -57,6 +58,7 @@ main = do
5758
_ <- evaluate $ force input7
5859
_ <- evaluate $ force input5
5960

61+
6062
defaultMainWithIngredients B.benchIngredients $ testGroup "kmerge"
6163
[ testGroup "tests"
6264
[ testGroup "merge"
@@ -75,7 +77,7 @@ main = do
7577
-- (because the input values are unformly random,
7678
-- there shouldn't be a lot of "cheap" leftovers elements,
7779
-- i.e. when other inputs are exhausted, but there are few)
78-
[ testCount "sortConcat" 3190 (L.sort . concat) input8
80+
[ testCount "sortConcat" comparisons8 (L.sort . concat) input8
7981
, testCount "listMerge" 3479 listMerge input8
8082
, testCount "treeMerge" 2391 treeMerge input8
8183
, testCount "heapMerge" 3168 heapMerge input8
@@ -115,7 +117,7 @@ main = do
115117
-- but I'm too lazy to think how to do that)
116118
--
117119
, testGroup "seven"
118-
[ testCount "sortConcat" 2691 (L.sort . concat) input7
120+
[ testCount "sortConcat" comparisons7 (L.sort . concat) input7
119121
, testCount "listMerge" 2682 listMerge input7
120122
, testCount "treeMerge" 1992 treeMerge input7
121123
, testCount "heapMerge" 2645 heapMerge input7
@@ -126,7 +128,7 @@ main = do
126128
-- and 2x100 with 3 comparisons.
127129
-- i.e. target is 1200 total comparisons.
128130
, testGroup "five"
129-
[ testCount "sortConcat" 1790 (L.sort . concat) input5
131+
[ testCount "sortConcat" comparisons5 (L.sort . concat) input5
130132
, testCount "listMerge" 1389 listMerge input5
131133
, testCount "treeMerge" 1291 treeMerge input5
132134
, testCount "heapMerge" 1485 heapMerge input5
@@ -139,7 +141,7 @@ main = do
139141
-- 4x125 elements with 3 comparisons
140142
-- i.e. target is 2000 total comparisons.
141143
, testGroup "levelling-min"
142-
[ testCount "sortConcat" 3729 (L.sort . concat) inputLevellingMin
144+
[ testCount "sortConcat" comparisonsMin (L.sort . concat) inputLevellingMin
143145
, testCount "listMerge" 2112 listMerge inputLevellingMin
144146
, testCount "treeMerge" 2730 treeMerge inputLevellingMin
145147
, testCount "heapMerge" 2655 heapMerge inputLevellingMin
@@ -153,7 +155,7 @@ main = do
153155
-- 4x 50 elements with 3 comparisons
154156
-- i.e. target is 1400 total comparisons.
155157
, testGroup "levelling-max"
156-
[ testCount "sortConcat" 3872 (L.sort . concat) inputLevellingMax
158+
[ testCount "sortConcat" comparisonsMax (L.sort . concat) inputLevellingMax
157159
, testCount "listMerge" 1440 listMerge inputLevellingMax
158160
, testCount "treeMerge" 2873 treeMerge inputLevellingMax
159161
, testCount "heapMerge" 1784 heapMerge inputLevellingMax
@@ -440,3 +442,27 @@ mutHeapMerge xss = case [ Heap.Entry x xs | x : xs <- xss ] of
440442
go !heap (Just (Heap.Entry x xs)) = fmap (x :) $ case xs of
441443
[] -> K.Heap.extract heap >>= go heap
442444
x':xs' -> K.Heap.replaceRoot heap (Heap.Entry x' xs') >>= go heap . Just
445+
446+
{-------------------------------------------------------------------------------
447+
Account for differing sort comparisons across base versions
448+
-------------------------------------------------------------------------------}
449+
450+
-- | The 'sort' and 'sortBy' implementations changed as of @base-4.21@.
451+
-- The new implementation performs fewer comparisons on longer lists.
452+
--
453+
-- Because of this, we fall back to the old sort method when the version of
454+
-- @base@ is @4.21@ or greater.
455+
comparisons5, comparisons7, comparisons8, comparisonsMin, comparisonsMax :: Int
456+
#if MIN_VERSION_base(4,21,0)
457+
comparisons5 = 1692
458+
comparisons7 = 2691
459+
comparisons8 = 3389
460+
comparisonsMin = 3606
461+
comparisonsMax = 3820
462+
#else
463+
comparisons5 = 1790
464+
comparisons7 = 2691
465+
comparisons8 = 3190
466+
comparisonsMin = 3729
467+
comparisonsMax = 3872
468+
#endif

0 commit comments

Comments
 (0)