Skip to content

Commit

Permalink
Adjust to hpqtypes 1.12.0.0 for real
Browse files Browse the repository at this point in the history
  • Loading branch information
arybczak committed Mar 8, 2024
1 parent 73476e7 commit 22020e6
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 69 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name: Fourmolu
on:
push:
branches:
- master
pull_request:
branches:
- master
on: push
jobs:
format:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
# Note that you must checkout your code before running fourmolu/fourmolu-action
- uses: actions/checkout@v2
- uses: fourmolu/fourmolu-action@v4
# Note that you must checkout your code before running haskell-actions/run-fourmolu
- uses: actions/checkout@v3
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.15.0.0"
74 changes: 27 additions & 47 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' '--config=cabal.haskell-ci' 'hpqtypes-effectful.cabal'
# haskell-ci 'github' '--config=cabal.haskell-ci' 'cabal.project'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.17.20231010
# version: 0.18.1
#
# REGENDATA ("0.17.20231010",["github","--config=cabal.haskell-ci","hpqtypes-effectful.cabal"])
# REGENDATA ("0.18.1",["github","--config=cabal.haskell-ci","cabal.project"])
#
name: Haskell-CI
on:
Expand Down Expand Up @@ -38,19 +38,19 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.8.1
- compiler: ghc-9.8.2
compilerKind: ghc
compilerVersion: 9.8.1
compilerVersion: 9.8.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.3
- compiler: ghc-9.6.4
compilerKind: ghc
compilerVersion: 9.6.3
compilerVersion: 9.6.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.7
- compiler: ghc-9.4.8
compilerKind: ghc
compilerVersion: 9.4.7
compilerVersion: 9.4.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.8
Expand All @@ -68,32 +68,17 @@ jobs:
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -105,22 +90,13 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -170,7 +146,7 @@ jobs:
- name: cache (tools)
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-0f8d33a5
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-9b3acae5
path: ~/.haskell-ci-tools
- name: install cabal-plan
run: |
Expand All @@ -189,7 +165,7 @@ jobs:
uses: actions/cache/save@v3
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-0f8d33a5
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-9b3acae5
path: ~/.haskell-ci-tools
- name: checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -219,6 +195,10 @@ jobs:
echo "package hpqtypes-effectful" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
source-repository-package
type: git
location: https://github.com/scrive/hpqtypes.git
tag: 498b34f35e38363a270f5af4c346c323e782a664
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(hpqtypes-effectful)$/; }' >> cabal.project.local
cat cabal.project
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# hpqtypes-effectful-1.0.1.0 (2023-12-18)
# hpqtypes-effectful-1.0.2.0 (2024-03-??)
* Compatibility with `hpqtypes` >= 1.12.0.0.

# hpqtypes-effectful-1.0.1.0 (2023-12-18)
* ~~Compatibility with `hpqtypes` >= 1.12.0.0.~~

# hpqtypes-effectful-1.0.0.1 (2023-03-28)
* Compatibility with `hpqtypes` >= 1.11.1.0.

Expand Down
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
packages: .

source-repository-package
type: git
location: https://github.com/scrive/hpqtypes.git
tag: 498b34f35e38363a270f5af4c346c323e782a664
45 changes: 44 additions & 1 deletion fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
# Number of spaces per indentation step
indentation: 2

# Max line length for automatic line breaking
column-limit: none

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: leading

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: leading

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: true

# Whether to leave a space before an opening record brace
record-brace-space: true

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: single-line
respectful: false

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: inline

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: no-space

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: never

# Whether to put parentheses around a single deriving class (choices: auto, always, or never)
single-deriving-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []
9 changes: 4 additions & 5 deletions hpqtypes-effectful.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.4
cabal-version: 3.0
build-type: Simple
name: hpqtypes-effectful
version: 1.0.1.0
version: 1.0.2.0
license: BSD-3-Clause
license-file: LICENSE
category: Database
Expand All @@ -16,8 +16,7 @@ extra-source-files:
CHANGELOG.md
README.md

tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.7 || ==9.6.3
|| ==9.8.1
tested-with: GHC == { 8.10.7, 9.0.2, 9.2.8, 9.4.8, 9.6.4, 9.8.2 }

bug-reports: https://github.com/haskell-effectful/hpqtypes-effectful/issues
source-repository head
Expand Down Expand Up @@ -59,7 +58,7 @@ library
build-depends: base >= 4.13 && < 5
, effectful-core >= 1.2.0.0 && < 3.0.0.0
, exceptions
, hpqtypes >= 1.11.1.0 && < 1.13.0.0
, hpqtypes >= 1.12.0.0 && < 1.13.0.0

hs-source-dirs: src

Expand Down
15 changes: 11 additions & 4 deletions src/Effectful/HPQTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ data DB :: Effect where
RunQuery :: IsSQL sql => sql -> DB m Int
GetQueryResult :: FromRow row => DB m (Maybe (QueryResult row))
ClearQueryResult :: DB m ()
GetBackendPid :: DB m BackendPid
GetConnectionStats :: DB m PQ.ConnectionStats
RunPreparedQuery :: IsSQL sql => PQ.QueryName -> sql -> DB m Int
GetLastQuery :: DB m SomeSQL
Expand All @@ -47,6 +48,7 @@ instance DB :> es => MonadDB (Eff es) where
runQuery = withFrozenCallStack $ send . RunQuery
getQueryResult = send GetQueryResult
clearQueryResult = send ClearQueryResult
getBackendPid = send GetBackendPid
getConnectionStats = withFrozenCallStack $ send GetConnectionStats
runPreparedQuery qn = withFrozenCallStack $ send . RunPreparedQuery qn
getLastQuery = send GetLastQuery
Expand Down Expand Up @@ -74,6 +76,7 @@ runDB connectionSource transactionSettings =
RunQuery sql -> unDBEff $ runQuery sql
GetQueryResult -> unDBEff getQueryResult
ClearQueryResult -> unDBEff clearQueryResult
GetBackendPid -> unDBEff getBackendPid
GetConnectionStats -> unDBEff getConnectionStats
RunPreparedQuery queryName sql -> unDBEff $ runPreparedQuery queryName sql
GetLastQuery -> unDBEff getLastQuery
Expand Down Expand Up @@ -160,8 +163,9 @@ modify = DBEff . State.modify
instance (IOE :> es) => MonadDB (DBEff es) where
runQuery sql = do
dbState <- get
(rows, res) <- liftIO $ PQ.runQueryIO (PQ.dbConnection dbState) sql
put $ PQ.updateStateWith dbState sql res
(rows, newDbState) <- liftIO $ PQ.updateStateWith dbState sql
=<< PQ.runQueryIO (PQ.dbConnection dbState) sql
put newDbState
pure rows

getQueryResult =
Expand All @@ -170,6 +174,8 @@ instance (IOE :> es) => MonadDB (DBEff es) where
clearQueryResult =
modify $ \st -> st {PQ.dbQueryResult = Nothing}

getBackendPid = liftIO . PQ.getBackendPidIO . PQ.dbConnection =<< get

getConnectionStats = do
dbState <- get
mconn <- liftIO . readMVar . PQ.unConnection $ PQ.dbConnection dbState
Expand All @@ -179,8 +185,9 @@ instance (IOE :> es) => MonadDB (DBEff es) where

runPreparedQuery queryName sql = do
dbState <- get
(rows, res) <- liftIO $ PQ.runPreparedQueryIO (PQ.dbConnection dbState) queryName sql
put $ PQ.updateStateWith dbState sql res
(rows, newDbState) <- liftIO $ PQ.updateStateWith dbState sql
=<< PQ.runPreparedQueryIO (PQ.dbConnection dbState) queryName sql
put newDbState
pure rows

getLastQuery = PQ.dbLastQuery <$> get
Expand Down

0 comments on commit 22020e6

Please sign in to comment.