diff --git a/.github/workflows/fourmolu.yaml b/.github/workflows/fourmolu.yaml index 624a215..f62a8fa 100644 --- a/.github/workflows/fourmolu.yaml +++ b/.github/workflows/fourmolu.yaml @@ -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" diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 7e7b18e..ac04d8d 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -1,6 +1,6 @@ # 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 # @@ -8,9 +8,9 @@ # # 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: @@ -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 @@ -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 }} @@ -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" @@ -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: | @@ -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 @@ -219,6 +195,10 @@ jobs: echo "package hpqtypes-effectful" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local cat cabal.project diff --git a/CHANGELOG.md b/CHANGELOG.md index bb419c7..6de6456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/cabal.project b/cabal.project index e6fdbad..80f1150 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,6 @@ packages: . + +source-repository-package + type: git + location: https://github.com/scrive/hpqtypes.git + tag: 498b34f35e38363a270f5af4c346c323e782a664 diff --git a/fourmolu.yaml b/fourmolu.yaml index 29faef9..b47fe72 100644 --- a/fourmolu.yaml +++ b/fourmolu.yaml @@ -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: [] diff --git a/hpqtypes-effectful.cabal b/hpqtypes-effectful.cabal index acf3c72..d9fe120 100644 --- a/hpqtypes-effectful.cabal +++ b/hpqtypes-effectful.cabal @@ -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 @@ -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 @@ -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 diff --git a/src/Effectful/HPQTypes.hs b/src/Effectful/HPQTypes.hs index 5085635..1979b44 100644 --- a/src/Effectful/HPQTypes.hs +++ b/src/Effectful/HPQTypes.hs @@ -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 @@ -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 @@ -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 @@ -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 = @@ -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 @@ -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