Skip to content

Commit 2c5da25

Browse files
Merge pull request #67 from brandonchinn178/updates
Update for GHC 9.8
2 parents 0825f4b + b0519d6 commit 2c5da25

8 files changed

+49
-61
lines changed

.github/workflows/ci.yml

+18-22
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,15 @@ jobs:
5757
strategy:
5858
matrix:
5959
ghc_version:
60-
- '8.10'
61-
- '9.0'
6260
- '9.4'
6361
- '9.6'
62+
- '9.8'
6463
persistent_version:
65-
- '2.13'
6664
- '2.14'
6765
include:
68-
- ghc_version: '8.10.1'
69-
persistent_version: '2.13'
66+
- ghc_version: '9.4.4'
67+
persistent_version: '2.14'
7068
oldest: true
71-
exclude:
72-
- ghc_version: '9.4'
73-
persistent_version: '2.13'
74-
- ghc_version: '9.6'
75-
persistent_version: '2.13'
7669

7770
name: compat_test (ghc-${{ matrix.ghc_version }}, persistent-${{ matrix.persistent_version }})
7871
runs-on: ubuntu-latest
@@ -94,27 +87,30 @@ jobs:
9487
--test-options='--color=always'
9588
--test-show-details=streaming
9689
--constraint='persistent ^>= ${{ matrix.persistent_version }}'
97-
--constraint='persistent < 2.13.3.4 || >= 2.14.0.2'
90+
--constraint='persistent >= 2.14.0.2'
9891
-
99-
# TODO: remove
100-
if: ${{ matrix.ghc_version == '9.6' }}
101-
run:
102-
cabal configure
103-
--enable-append
104-
--allow-newer='persistent:template-haskell'
105-
--allow-newer='unliftio-pool:transformers'
106-
--allow-newer='explainable-predicates:base'
107-
--allow-newer='explainable-predicates:template-haskell'
92+
# https://github.com/bitemyapp/esqueleto/pull/381
93+
if: ${{ matrix.ghc_version == '9.8' }}
94+
name: Patch esqueleto
95+
run: |
96+
cabal configure --enable-append --allow-newer esqueleto:text
97+
cat >> cabal.project.local <<EOF
98+
source-repository-package
99+
type: git
100+
location: https://github.com/MercuryTechnologies/esqueleto.git
101+
tag: 94d27de57072a823d97bd9868b33c45545c067c4
102+
EOF
108103
-
109104
if: ${{ matrix.oldest }}
110105
name: Use oldest dependencies
111106
run:
112107
cabal configure
113108
--enable-append --prefer-oldest
114-
--constraint 'conduit >= 1.3.1'
109+
--constraint 'array installed'
110+
--constraint 'time installed'
111+
--constraint 'persistent-sqlite > 2.13.0.3'
115112
--constraint 'silently >= 0.0.3'
116113
--constraint 'string-conversions >= 0.4'
117-
--constraint 'unix-time >= 0.3.8'
118114
-
119115
name: Get build plan
120116
run: cabal build --dry-run

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Unreleased
22

3+
# v0.5.1
4+
5+
* Add GHC 9.8 support
6+
* Drop support for GHC < 9.4
7+
38
# v0.5.0.1
49

510
* Add GHC 9.4 support

package.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: persistent-mtl
2-
version: 0.5.0.1
2+
version: 0.5.1
33
maintainer: Brandon Chinn <[email protected]>
44
synopsis: Monad transformer for the persistent API
55
description: |
@@ -28,7 +28,7 @@ library:
2828
- persistent >= 2.13 && < 2.15
2929
- resource-pool < 1
3030
- resourcet < 1.4
31-
- text < 2.1
31+
- text < 2.2
3232
- transformers < 0.7
3333
- unliftio < 0.3
3434
- unliftio-core < 0.3
@@ -37,7 +37,6 @@ library:
3737
when:
3838
# https://gitlab.haskell.org/ghc/ghc/-/issues/20836
3939
- condition: >
40-
impl(ghc >= 9.2.0) && impl(ghc < 9.3) ||
4140
impl(ghc >= 9.4.0) && impl(ghc < 9.4.3)
4241
buildable: false
4342

persistent-mtl.cabal

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.35.2.
3+
-- This file has been generated from package.yaml by hpack version 0.36.0.
44
--
55
-- see: https://github.com/sol/hpack
66

77
name: persistent-mtl
8-
version: 0.5.0.1
8+
version: 0.5.1
99
synopsis: Monad transformer for the persistent API
1010
description: A monad transformer and mtl-style type class for using the
1111
persistent API directly in your monad transformer stack.
@@ -53,13 +53,13 @@ library
5353
, persistent >=2.13 && <2.15
5454
, resource-pool <1
5555
, resourcet <1.4
56-
, text <2.1
56+
, text <2.2
5757
, transformers <0.7
5858
, unliftio <0.3
5959
, unliftio-core <0.3
6060
, unliftio-pool <1
6161
default-language: Haskell2010
62-
if impl(ghc >= 9.2.0) && impl(ghc < 9.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.4.3)
62+
if impl(ghc >= 9.4.0) && impl(ghc < 9.4.3)
6363

6464
buildable: False
6565

stack.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
resolver: lts-19.33
2-
3-
extra-deps:
4-
- tasty-autocollect-0.3.0.0
5-
# https://github.com/yesodweb/persistent/issues/1406#issuecomment-1226741099
6-
- persistent-2.13.3.3
1+
resolver: lts-22.3
72

83
ghc-options:
94
'$locals': -Werror

stack.yaml.lock

+5-19
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,10 @@
33
# For more information, please see the documentation at:
44
# https://docs.haskellstack.org/en/stable/lock_files
55

6-
packages:
7-
- completed:
8-
hackage: tasty-autocollect-0.3.0.0@sha256:9026c5a96bb871513a4213ae3c9105538f12bb5ad6400fe05a56c69e6fc85424,4734
9-
pantry-tree:
10-
sha256: e796c1754a91aec1953da308cf5d9751a6b2bd219666fb2fe89672a244d7ba13
11-
size: 3903
12-
original:
13-
hackage: tasty-autocollect-0.3.0.0
14-
- completed:
15-
hackage: persistent-2.13.3.3@sha256:28aa9bebabb4a2b91e86ddc4cf994bd8a4b5b61ed807c163a44523b218577311,7050
16-
pantry-tree:
17-
sha256: 0113b5721e15e0c1cac9a135c77e659521a4217878ef9eabc237e68a80ac3671
18-
size: 6052
19-
original:
20-
hackage: persistent-2.13.3.3
6+
packages: []
217
snapshots:
228
- completed:
23-
sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4
24-
size: 619204
25-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml
26-
original: lts-19.33
9+
sha256: 53a2800f7fe0c4628af0e7d5e985707dd3af9863ac3983a43c835dbaa8ed5f35
10+
size: 714094
11+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/3.yaml
12+
original: lts-22.3

test/IntegrationTest.hs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{- AUTOCOLLECT.TEST -}
2+
{-# LANGUAGE LambdaCase #-}
23
{-# LANGUAGE NamedFieldPuns #-}
34
{-# LANGUAGE OverloadedStrings #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
@@ -698,20 +699,20 @@ testPersistentAPI backendType =
698699
result <- runTestApp backendType $ do
699700
insertMany_ [person "Alice", person "Bob"]
700701
withRawQuery "SELECT name FROM person" [] $
701-
Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
702+
Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
702703

703704
result @?= ["Alice", "Bob"]
704705
, testCase "rawQueryRes" $ do
705706
result <- runTestApp backendType $ do
706707
insertMany_ [person "Alice", person "Bob"]
707708
acquire <- rawQueryRes "SELECT name FROM person" []
708709
Acquire.with acquire $ \conduit ->
709-
runConduit $ conduit .| Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
710+
runConduit $ conduit .| Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
710711
result @?= ["Alice", "Bob"]
711712
, testCase "rawQuery" $ do
712713
result <- runTestApp backendType $ do
713714
insertMany_ [person "Alice", person "Bob"]
714-
runConduit $ rawQuery "SELECT name FROM person" [] .| Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
715+
runConduit $ rawQuery "SELECT name FROM person" [] .| Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
715716
result @?= ["Alice", "Bob"]
716717
, testCase "rawExecute" $ do
717718
result <- runTestApp backendType $ do
@@ -792,8 +793,13 @@ testInterop backendType =
792793

793794
{- Persistent helpers -}
794795

795-
fromPersistValue' :: (PersistField a) => PersistValue -> a
796-
fromPersistValue' = either (error . Text.unpack) id . fromPersistValue
796+
getFirstPersistValue :: (PersistField a) => [PersistValue] -> a
797+
getFirstPersistValue = \case
798+
[] -> error "Unexpectedly got no values"
799+
v : _ -> fromPersistValueOrFail v
800+
801+
fromPersistValueOrFail :: (PersistField a) => PersistValue -> a
802+
fromPersistValueOrFail = either (error . Text.unpack) id . fromPersistValue
797803

798804
{- Meta SQL helpers -}
799805

test/MockedTest.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Conduit (runConduit, runResourceT, (.|))
1212
import qualified Conduit
1313
import qualified Data.Acquire as Acquire
1414
import qualified Data.Map.Strict as Map
15+
import Data.Maybe (listToMaybe)
1516
import Database.Persist.Sql (
1617
Entity (..),
1718
Single (..),
@@ -48,8 +49,8 @@ test =
4849
case result of
4950
Right _ -> assertFailure "runMockSqlQueryT did not fail"
5051
Left e -> do
51-
let msg = head $ lines $ show (e :: SomeException)
52-
msg @?= "Could not find mock for query: SelectList{..}<Person>"
52+
let msg = listToMaybe $ lines $ show (e :: SomeException)
53+
msg @?= Just "Could not find mock for query: SelectList{..}<Person>"
5354
, testCase "it continues after a mock doesn't match" $ do
5455
result <-
5556
runMockSqlQueryT

0 commit comments

Comments
 (0)