Skip to content

Commit ea610e9

Browse files
authored
Support latest GHCs (#6)
1 parent 0f3de05 commit ea610e9

File tree

6 files changed

+54
-61
lines changed

6 files changed

+54
-61
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,51 @@
1-
name: Tests
1+
name: CI
22

3+
# Trigger the workflow on push or pull request, but only for the main branch
34
on:
45
pull_request:
56
push:
67
branches: ["main"]
78

89
jobs:
9-
generateMatrix:
10-
name: "Generate matrix"
11-
runs-on: ubuntu-latest
10+
generate-matrix:
11+
name: "Generate matrix from cabal"
1212
outputs:
1313
matrix: ${{ steps.set-matrix.outputs.matrix }}
14+
runs-on: ubuntu-latest
1415
steps:
15-
- name: Checkout base repo
16-
uses: actions/checkout@v3
1716
- name: Extract the tested GHC versions
1817
id: set-matrix
19-
run: |
20-
wget -q https://github.com/Kleidukos/get-tested/releases/download/v0.1.4.0/get-tested-0.1.4.0-linux-amd64 -O get-tested
21-
chmod +x get-tested
22-
./get-tested --ubuntu pg-transact-effectful.cabal >> $GITHUB_OUTPUT
23-
18+
uses: kleidukos/get-tested@v0.1.7.0
19+
with:
20+
cabal-file: pg-transact-effectful.cabal
21+
ubuntu-version: "latest"
22+
version: 0.1.7.0
2423
tests:
2524
name: ${{ matrix.ghc }} on ${{ matrix.os }}
26-
needs: generateMatrix
25+
needs: generate-matrix
2726
runs-on: ${{ matrix.os }}
2827
strategy:
29-
matrix: ${{ fromJSON(needs.generateMatrix.outputs.matrix) }}
28+
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
3029
steps:
31-
- name: Checkout base repo
32-
uses: actions/checkout@v3
33-
34-
- name: "Configure ghcup"
35-
run: |
36-
ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
37-
38-
- name: Set up Haskell
39-
id: setup-haskell
40-
uses: haskell/actions/setup@v2
41-
with:
42-
ghc-version: "${{ matrix.ghc }}"
43-
cabal-version: "latest"
44-
45-
- name: Configure environment
46-
run: |
47-
# sudo apt install -y postgresql-14 libpq-dev
48-
# echo "/usr/lib/postgresql/14/bin/" >> $GITHUB_PATH
49-
echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
50-
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
51-
echo "$HOME/.local/bin" >> $GITHUB_PATH
52-
cabal freeze
53-
54-
- name: Cache
55-
uses: actions/cache@v3
56-
with:
57-
path: ${{ steps.setup-haskell.outputs.cabal-store }}
58-
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
59-
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
60-
61-
- name: Build
62-
run: |
63-
make build
30+
- name: Checkout base repo
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Haskell
34+
id: setup-haskell
35+
uses: haskell-actions/setup@v2
36+
with:
37+
ghc-version: ${{ matrix.ghc }}
38+
cabal-version: 'latest'
39+
40+
- name: Freeze
41+
run: cabal freeze
42+
43+
- name: Haskell cache restoration
44+
uses: actions/cache@v4.2.0
45+
with:
46+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
47+
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/plan.json') }}
48+
restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}-
49+
50+
- name: Build Library
51+
run: cabal build pg-transact-effectful

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- uses: haskell-actions/run-fourmolu@v9
1515
with:
16-
version: "0.12.0.0"
16+
version: "0.17.0.0"
1717
pattern: |
1818
src/**/*.hs
1919

fourmolu.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import-export-style: leading
44
record-brace-space: false # rec {x = 1} vs. rec{x = 1}
55
indent-wheres: true # 'false' means save space by only half-indenting the 'where' keyword
66
respectful: true # don't be too opinionated about newlines etc.
7-
haddock-style: multi-line-compact # '--' vs. '{-'
7+
haddock-style: single-line # '--' vs. '{-'
88
newlines-between-decls: 1 # number of newlines between top-level declarations
99
fixities: []
1010
function-arrows: leading
11+
single-constraint-parens: never
12+
import-grouping: by-scope
13+
sort-constraints: true
14+
sort-derived-classes: true
15+
sort-deriving-clauses: true

pg-transact-effectful.cabal

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ maintainer: Hécate Moonlight
88
license: MIT
99
build-type: Simple
1010
extra-source-files:
11-
CHANGELOG.md
1211
LICENSE.md
1312
README.md
1413

15-
tested-with:
16-
GHC ==9.4.7 || ==9.6.3
14+
extra-doc-files: CHANGELOG.md
15+
tested-with: GHC ==9.6.6 || ==9.8.4 || ==9.10.1
1716

1817
source-repository head
1918
type: git
@@ -36,7 +35,7 @@ common common-extensions
3635

3736
common common-ghc-options
3837
ghc-options:
39-
-Wall -Wcompat -Werror -Widentities -Wincomplete-record-updates
38+
-Wall -Wcompat -Widentities -Wincomplete-record-updates
4039
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
4140
-fhide-source-paths -Wno-unused-do-bind
4241
-Wno-unticked-promoted-constructors
@@ -53,9 +52,9 @@ library
5352
Effectful.PostgreSQL.Transact.Effect
5453

5554
build-depends:
56-
, base <4.19.0
55+
, base <4.22.0
5756
, deepseq
58-
, effectful-core ^>=2.3
57+
, effectful-core >=2.3
5958
, mtl
6059
, pg-transact
6160
, postgresql-simple

src/Effectful/PostgreSQL/Transact.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import Data.Kind (Type)
66
import Database.PostgreSQL.Simple (FromRow, Query, ToRow)
77
import qualified Database.PostgreSQL.Transact as DBT
88
import Effectful (Eff, Effect, type (:>))
9+
910
import Effectful.PostgreSQL.Transact.Effect
1011

1112
query
1213
:: forall (es :: [Effect]) (parameters :: Type) (b :: Type)
13-
. (DB :> es, ToRow parameters, FromRow b, NFData b)
14+
. (DB :> es, FromRow b, NFData b, ToRow parameters)
1415
=> Query
1516
-> parameters
1617
-> Eff es [b]
@@ -25,7 +26,7 @@ query_ q = dbtToEff $ DBT.query_ q
2526

2627
queryOne
2728
:: forall (es :: [Effect]) (parameters :: Type) (b :: Type)
28-
. (DB :> es, ToRow parameters, FromRow b, NFData b)
29+
. (DB :> es, FromRow b, NFData b, ToRow parameters)
2930
=> Query
3031
-> parameters
3132
-> Eff es (Maybe b)
@@ -40,22 +41,22 @@ queryOne_ q = dbtToEff $ DBT.queryOne_ q
4041

4142
execute
4243
:: forall (es :: [Effect]) (parameters :: Type)
43-
. (ToRow parameters, DB :> es)
44+
. (DB :> es, ToRow parameters)
4445
=> Query
4546
-> parameters
4647
-> Eff es Int64
4748
execute q parameters = dbtToEff $ DBT.execute q parameters
4849

4950
execute_
5051
:: forall (es :: [Effect])
51-
. (DB :> es)
52+
. DB :> es
5253
=> Query
5354
-> Eff es Int64
5455
execute_ q = dbtToEff $ DBT.execute_ q
5556

5657
executeMany
5758
:: forall (es :: [Effect]) (parameters :: Type)
58-
. (ToRow parameters, DB :> es)
59+
. (DB :> es, ToRow parameters)
5960
=> Query
6061
-> [parameters]
6162
-> Eff es Int64

src/Effectful/PostgreSQL/Transact/Effect.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ newtype instance StaticRep DB = DB (Pool Connection)
2424

2525
runDB
2626
:: forall (es :: [Effect]) (a :: Type)
27-
. (IOE :> es)
27+
. IOE :> es
2828
=> Pool Connection
2929
-> Eff (DB : es) a
3030
-> Eff es a
3131
runDB pool m = do
3232
evalStaticRep (DB pool) m
3333

34-
getPool :: (DB :> es) => Eff es (Pool Connection)
34+
getPool :: DB :> es => Eff es (Pool Connection)
3535
getPool = do
3636
DB pool <- getStaticRep
3737
pure pool

0 commit comments

Comments
 (0)