From 9772b60922a530082c35d035599ab78e36491875 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 11:04:21 -0300 Subject: [PATCH 1/9] Support GHC 9.12.2 This bumps dependency bounds, but also tests GHC 9.12.2 in CI and addresses _some_ (not all) compilation warnings. --- .github/workflows/main.yml | 23 +++++++----------- .hlint.yaml | 1 + Runfile | 24 ++++++++++--------- .../hpgsql-simple-compat.cabal | 4 ++-- hpgsql/hpgsql.cabal | 7 +++--- hpgsql/src/Hpgsql/Encoding.hs | 2 +- hpgsql/src/Hpgsql/Types.hs | 14 ++++++++++- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 505114c..aa8c617 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,26 +51,21 @@ jobs: # interruption safety, MVars and STM, so we test the single threaded # runtime, too. # We also vary things like PGHOST to test both TCP and Unix Domain Sockets. - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14,single-threaded-rts,ghc984,ghc967 \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-tests.txt nix-build --no-out-link -A testsPg18' \ + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122--tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-tests.txt nix-build --no-out-link -A testsPg16' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-tests.txt nix-build --no-out-link -A testsPg15' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-tests.txt nix-build --no-out-link -A testsPg14' \ - 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg18' + 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ + 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14' - name: Run hpgsql-simple-compat tests run: | - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14,ghc984,ghc967 \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg18' \ + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984,pg15,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A hpgsqlSimpleCompatTestsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg17' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg16' \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg16' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg15' \ - 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg14' \ - 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg18' \ - 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg18' + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg14' build-aarch64-darwin: runs-on: macos-14 diff --git a/.hlint.yaml b/.hlint.yaml index 76dc978..fd31108 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -4,6 +4,7 @@ - arguments: - "--cpp-define=MIN_VERSION_base(a,b,c)=1" + - "--cpp-define=MIN_VERSION_GLASGOW_HASKELL(9,12,0,0)=0" - "-XQuasiQuotes" - "-XTemplateHaskell" - "-XOverloadedRecordDot" diff --git a/Runfile b/Runfile index 05b3e0d..c6dc51e 100644 --- a/Runfile +++ b/Runfile @@ -31,17 +31,19 @@ ci-tests: hlint . - concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14 \ - 'nix-build --no-out-link -A testsPg18' \ - 'nix-build --no-out-link -A testsPg17' \ - 'nix-build --no-out-link -A testsPg16' \ - 'nix-build --no-out-link -A testsPg15' \ - 'nix-build --no-out-link -A testsPg14' - - # concurrently -g --timings --names single-threaded,ghc984,ghc967 \ - # 'nix-build --no-out-link --argstr threading "-threaded" -A testsPg18' \ - # 'nix-build --no-out-link --argstr ghc ghc984 -A testsPg18' \ - # 'nix-build --no-out-link --argstr ghc ghc967 -A testsPg18' + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122--tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ + 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ + 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14' + + concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984,pg15,pg14-ghc967 \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A hpgsqlSimpleCompatTestsPg18' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg17' \ + 'nix-build --no-out-link --argstr ghc ghc984 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A hpgsqlSimpleCompatTestsPg16' \ + 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg15' \ + 'nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-simple-compat-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-simple-compat-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A hpgsqlSimpleCompatTestsPg14' ## diff --git a/hpgsql-simple-compat/hpgsql-simple-compat.cabal b/hpgsql-simple-compat/hpgsql-simple-compat.cabal index c490b38..7582d64 100644 --- a/hpgsql-simple-compat/hpgsql-simple-compat.cabal +++ b/hpgsql-simple-compat/hpgsql-simple-compat.cabal @@ -84,11 +84,11 @@ library -- GHC bundled libs build-depends: - base >= 4.18 && < 4.21 + base >= 4.18 && < 4.22 , bytestring >= 0.11 && < 0.13 , case-insensitive >= 1.2 && < 1.3 , containers >= 0.6 && < 0.8 - , template-haskell >= 2.20 && < 2.23 + , template-haskell >= 2.20 && < 2.24 , text >= 2.0 && < 2.2 , aeson >= 2.2 && < 2.3 , attoparsec >= 0.14 && < 0.15 diff --git a/hpgsql/hpgsql.cabal b/hpgsql/hpgsql.cabal index 8f162d2..9d0343f 100644 --- a/hpgsql/hpgsql.cabal +++ b/hpgsql/hpgsql.cabal @@ -17,6 +17,7 @@ tested-with: GHC ==9.6.7 || ==9.8.4 || ==9.10.3 + || ==9.12.2 source-repository head type: git @@ -95,7 +96,7 @@ library Only >= 0.1 && < 0.2, aeson >= 2.2 && < 2.3, attoparsec >= 0.14 && < 0.15, - base >= 4.18 && < 4.21, + base >= 4.18 && < 4.22, bytestring >= 0.11 && < 0.13, case-insensitive >= 1.2 && < 1.3, cereal >= 0.5 && < 0.6, @@ -110,9 +111,9 @@ library scientific >= 0.3 && < 0.4, stm >= 2.5 && < 2.6, streaming >= 0.2 && < 0.3, - template-haskell >= 2.20 && < 2.23, + template-haskell >= 2.20 && < 2.24, text >= 2.0 && < 2.2, - time >= 1.12 && < 1.13, + time >= 1.12 && < 1.15, transformers >= 0.6 && < 0.7, uuid-types >= 1.0 && < 1.1, vector >= 0.13 && < 0.14 diff --git a/hpgsql/src/Hpgsql/Encoding.hs b/hpgsql/src/Hpgsql/Encoding.hs index 7c6dbed..3636db3 100644 --- a/hpgsql/src/Hpgsql/Encoding.hs +++ b/hpgsql/src/Hpgsql/Encoding.hs @@ -397,7 +397,7 @@ instance ToPgField Scientific where calculateDigits :: Int16 -> Int16 -> Integer -> BS.ByteString -> (Int16, Int16, BS.ByteString) calculateDigits !ndigitsSoFar !weightSoFar 0 !encodedDigits = (ndigitsSoFar, weightSoFar, encodedDigits) calculateDigits !ndigitsSoFar !weightSoFar !val !encodedDigits = - let (quotient, fromIntegral -> rest :: Int16) = val `divMod` 10000 + let (quotient, fromIntegral -> (rest :: Int16)) = val `divMod` 10000 in calculateDigits (ndigitsSoFar + 1) (weightSoFar + 1) diff --git a/hpgsql/src/Hpgsql/Types.hs b/hpgsql/src/Hpgsql/Types.hs index e38f53b..2378e93 100644 --- a/hpgsql/src/Hpgsql/Types.hs +++ b/hpgsql/src/Hpgsql/Types.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module Hpgsql.Types ( Only (..), Aeson (..), @@ -17,7 +19,11 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Lazy as LBS import Data.Tuple.Only (Only (..)) +#if MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) +import Data.Typeable (Proxy (..)) +#else import Data.Typeable (Proxy (..), Typeable) +#endif import Hpgsql.Builder (BinaryField (..)) import Hpgsql.Encoding (FieldDecoder (..), FieldEncoder (..), FieldInfo (..), FromPgField (..), FromPgRow (..), RowEncoder (..), ToPgField (..), ToPgRow (..), arrayField, toPgVectorField) import Hpgsql.TypeInfo (EncodingContext (..), TypeInfo (..), jsonOid, jsonbOid, lookupTypeByOid) @@ -101,7 +107,13 @@ instance FromPgField PgJson where -- into your type (from either json or jsonb), and to encode -- to jsonb. newtype Aeson a = Aeson {getAeson :: a} - deriving (Eq, Show, Read, Typeable, Functor) + deriving newtype (Eq) +#if MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + deriving stock (Functor, Read, Show) +#else + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving stock (Show, Read, Typeable, Functor) +#endif instance (FromJSON a) => FromPgField (Aeson a) where fieldDecoder = From 62636082500649df64a13104cf26aae52c332715 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 11:06:04 -0300 Subject: [PATCH 2/9] Small improvements to READMEs --- INTERRUPTION-SAFETY.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/INTERRUPTION-SAFETY.md b/INTERRUPTION-SAFETY.md index 381f4cb..f1f8c10 100644 --- a/INTERRUPTION-SAFETY.md +++ b/INTERRUPTION-SAFETY.md @@ -21,8 +21,8 @@ withTransaction $ With Hpgsql you shouldn't run into such issues, or at least we promise that: - Hpgsql is interruption-safe, so a query can be interrupted by asynchronous exceptions and you should still be able to run new queries on the same connection without any other side-effects. Naturally, it is up to you to determine which queries ran or not to completion, since they might have side-effects*. - Hpgsql will throw either `PostgresError` or `IrrecoverableHpgsqlError`, and: - - If you receive a `IrrecoverableHpgsqlError`, Hpgsql makes no promises about which statements ran to completion and what connection state is, and you should `closeForcefully` the connection without running any other queries. These errors should only be thrown for "obvious" developer mistakes from which usually there would be no way to proceed, anyway. + - If you receive a `IrrecoverableHpgsqlError`, Hpgsql makes no promises about which statements ran to completion and what the connection state is. You should `closeForcefully` the connection without running any other queries. These errors should only be thrown for "obvious" developer mistakes from which usually there would be no way to proceed, anyway. - If you receive a `PostgresError` exception, postgres and Hpgsql's states are synced and you can issue new queries afterwards. - - It is possible Hpgsql throws a different kind of exception. File a bug report if that happens, and if you know it came from Hpgsql, treat it like a `IrrecoverableHpgsqlError`. + - You can file a bug report if Hpgsql throws a different kind of exception, and we'll treat it like a bug. * There are edge cases with different behaviour, but hpgsql will document them or throw an `IrrecoverableHpgsqlError` with informative instructions. diff --git a/README.md b/README.md index 8b0c9ff..1fde719 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ f val = do ## Current status -Hpgsql is in active development, is new and has not been used in Production yet. It currently lacks (at least) many of the authentication methods that libpq provides; for now only cleartext and MD5 password auth are supported, and only unencrypted connections. +Hpgsql is in active development, is new and has not been used in Production yet. It currently lacks many of the authentication methods that libpq provides; for now only cleartext, MD5 and SCRAM-SHA-256 password auth are supported, and only unencrypted connections. That being said, one of my other projects, codd, [has a tests-passing branch using hpgsql-simple-compat](https://github.com/mzabani/codd/pull/227) (the nearly API compatible fork of postgresql-simple described in the next section) with very few modifications. From 9e2e11a5bda22495a2816a64442223d75661c0e9 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 11:09:48 -0300 Subject: [PATCH 3/9] Run tests with varied GHC versions for MacOS too Why not? --- .github/workflows/main.yml | 10 +++++----- Runfile | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa8c617..86c4dd4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,7 @@ jobs: # runtime, too. # We also vary things like PGHOST to test both TCP and Unix Domain Sockets. concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ - 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122--tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ @@ -98,11 +98,11 @@ jobs: run: | # We don't run these concurrently because Nix does not have a sandbox in Macs, so it's # not worth the risk. - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-tests.txt nix-build --no-out-link -A testsPg18 + nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18 timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-tests.txt nix-build --no-out-link -A testsPg16 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-tests.txt nix-build --no-out-link -A testsPg15 - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-tests.txt nix-build --no-out-link -A testsPg14 + nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16 + nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15 + nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14 - name: Run tests with different combinations run: | diff --git a/Runfile b/Runfile index c6dc51e..bcb45a5 100644 --- a/Runfile +++ b/Runfile @@ -32,7 +32,7 @@ ci-tests: hlint . concurrently -g --timings --names pg18-ghc9122,pg17,pg16-ghc984-tcp,pg15-single-threaded-rts,pg14-ghc967 \ - 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122--tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ + 'nix-build --no-out-link --argstr ghc ghc9122 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-ghc9122-tests.txt nix-build --no-out-link --argstr ghc ghc9122 -A testsPg18' \ 'timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg17-tests.txt nix-build --no-out-link -A testsPg17' \ 'nix-build --no-out-link --argstr ghc ghc984 --argstr PGHOST localhost -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg16-ghc984-tests.txt nix-build --no-out-link --argstr ghc ghc984 -A testsPg16' \ 'nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15' \ From 0581678c7cbb8b4490eeabc53775ce66b50f58a4 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 11:40:46 -0300 Subject: [PATCH 4/9] MacOS tests are now diverse enough --- .github/workflows/main.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86c4dd4..497bf43 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -104,16 +104,6 @@ jobs: nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg15-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" -A testsPg15 nix-build --no-out-link --argstr ghc ghc967 -A hpgsql-tests && timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg14-ghc967-tests.txt nix-build --no-out-link --argstr ghc ghc967 -A testsPg14 - - name: Run tests with different combinations - run: | - # GHC's single and multi-threaded runtimes are different with respect - # to many things, and our library relies on a lot of ThreadId tracking, - # interruption safety, MVars and STM, so we test the single threaded - # runtime, too. - # We also vary things like PGHOST to test both TCP and Unix Domain Sockets. - nix-build --no-out-link --argstr threading "-threaded" -A hpgsql-tests - timeout 5m scripts/ci/run-tests-and-annotate-with-error.sh local/pg18-single-threaded-rts-tests.txt nix-build --no-out-link --argstr threading "-threaded" --argstr PGHOST localhost -A testsPg18 - - name: Run hpgsql-simple-compat tests run: | scripts/ci/run-tests-and-annotate-with-error.sh local/hpgsql-simple-compat-tests.txt nix-build --no-out-link -A hpgsqlSimpleCompatTestsPg18 From 9156b79f14ccac002088d1e987401892c7b9d89b Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 12:05:41 -0300 Subject: [PATCH 5/9] Get rid of all Typeable compilation warnings with CPP This is not pretty... --- .../hpgsql-simple-compat.cabal | 3 - .../src/Database/PostgreSQL/Simple/Copy.hs | 10 +++- .../src/Database/PostgreSQL/Simple/Errors.hs | 14 +++-- .../Database/PostgreSQL/Simple/FromField.hs | 12 +++- .../Simple/HStore/Implementation.hs | 25 ++++++-- .../Database/PostgreSQL/Simple/Internal.hs | 34 +++++++++-- .../src/Database/PostgreSQL/Simple/Ok.hs | 18 +++++- .../src/Database/PostgreSQL/Simple/Range.hs | 16 +++++- .../src/Database/PostgreSQL/Simple/ToField.hs | 6 ++ .../src/Database/PostgreSQL/Simple/Types.hs | 57 ++++++++++++++++--- hpgsql/src/Hpgsql/Types.hs | 7 +-- 11 files changed, 164 insertions(+), 38 deletions(-) diff --git a/hpgsql-simple-compat/hpgsql-simple-compat.cabal b/hpgsql-simple-compat/hpgsql-simple-compat.cabal index 7582d64..2143b90 100644 --- a/hpgsql-simple-compat/hpgsql-simple-compat.cabal +++ b/hpgsql-simple-compat/hpgsql-simple-compat.cabal @@ -92,13 +92,10 @@ library , text >= 2.0 && < 2.2 , aeson >= 2.2 && < 2.3 , attoparsec >= 0.14 && < 0.15 - , haskell-src-meta >= 0.8 && < 0.9 , hpgsql >= 0.2 && < 0.3 , hashable >= 1.5 && < 1.6 , mtl >= 2.3 && < 2.4 - , streaming >= 0.2 && < 0.3 , time-compat >= 1.9 && < 1.10 - , transformers >= 0.6 && < 0.7 , Only >= 0.1 && < 0.2 , scientific >= 0.3 && < 0.4 , uuid-types >= 1.0 && < 1.1 diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs index 1511e80..a1f6972 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -42,7 +44,9 @@ import qualified Data.ByteString.Char8 as B import Data.Int (Int64) import qualified Data.Text as Text import Data.Text.Encoding (decodeUtf8) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) import Data.Typeable (Typeable) +#endif import Database.PostgreSQL.Simple.HpgsqlUtils (toHpgsqlQuery) import Database.PostgreSQL.Simple.Internal import Database.PostgreSQL.Simple.ToRow (ToRow) @@ -80,7 +84,11 @@ data CopyOutResult | -- | No more rows, and a count of the -- number of rows returned. CopyOutDone {-# UNPACK #-} !Int64 - deriving (Eq, Typeable, Show) + deriving (Eq, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | Feed some data to a @COPY FROM STDIN@ query. Note that -- the data does not need to represent a single row, or even an diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs index 603b1be..af3c9b0 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ---------------------------------------------------------- @@ -25,11 +27,11 @@ module Database.PostgreSQL.Simple.Errors where import Control.Exception as E - import Data.Attoparsec.ByteString.Char8 import Data.ByteString (ByteString) -import Data.Typeable - +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) +import Data.Typeable (Typeable) +#endif import Database.PostgreSQL.Simple.Internal -- Examples of parsed error messages @@ -55,7 +57,11 @@ data ConstraintViolation CheckViolation ByteString ByteString | -- | Name of the exclusion violation constraint ExclusionViolation ByteString - deriving (Show, Eq, Ord, Typeable) + deriving (Show, Eq, Ord) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- Default instance should be enough instance Exception ConstraintViolation where diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs index 145c2ff..6f03a89 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | -- Module: Database.PostgreSQL.Simple.FromField -- Copyright: (c) 2011 MailRank, Inc. @@ -157,7 +159,11 @@ data ResultError errHaskellType :: String, errMessage :: String } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance Exception ResultError where toException = postgresqlExceptionToException @@ -176,8 +182,8 @@ class FromField a where fromField = let dec = Hpgsql.fieldDecoder in \f -> - if (Hpgsql.allowedPgTypes dec) f - then \mbs -> Conversion $ \_encCtx -> case (Hpgsql.fieldValueDecoder dec) f mbs of + if Hpgsql.allowedPgTypes dec f + then \mbs -> Conversion $ \_encCtx -> case Hpgsql.fieldValueDecoder dec f mbs of Right v -> Ok v Left err -> Errors [toException $ userError err] else \_ -> Conversion $ \_encCtx -> Errors [toException $ userError "Invalid type OID for FromField instance"] diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs index 10ee778..a542a07 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -27,7 +28,9 @@ import qualified Data.Text as TS import qualified Data.Text.Encoding as TS import Data.Text.Encoding.Error (UnicodeException) import qualified Data.Text.Lazy as TL -import Data.Typeable +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) +import Data.Typeable (Typeable) +#endif class ToHStore a where toHStore :: a -> HStoreBuilder @@ -36,7 +39,10 @@ class ToHStore a where data HStoreBuilder = Empty | Comma !Builder +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) +#endif instance ToHStore HStoreBuilder where toHStore = id @@ -68,7 +74,10 @@ class ToHStoreText a where -- | Represents escape text, ready to be the key or value to a hstore value newtype HStoreText = HStoreText Builder - deriving stock (Typeable) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif deriving newtype (Semigroup, Monoid) instance ToHStoreText HStoreText where @@ -112,13 +121,21 @@ hstore (toHStoreText -> (HStoreText key)) (toHStoreText -> (HStoreText val)) = `mappend` char8 '"' ) -newtype HStoreList = HStoreList {fromHStoreList :: [(Text, Text)]} deriving (Typeable, Show) +newtype HStoreList = HStoreList {fromHStoreList :: [(Text, Text)]} deriving (Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | hstore instance ToHStore HStoreList where toHStore (HStoreList xs) = mconcat (map (uncurry hstore) xs) -newtype HStoreMap = HStoreMap {fromHStoreMap :: Map Text Text} deriving (Eq, Ord, Typeable, Show) +newtype HStoreMap = HStoreMap {fromHStoreMap :: Map Text Text} deriving (Eq, Ord, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance ToHStore HStoreMap where toHStore (HStoreMap xs) = Map.foldrWithKey f mempty xs diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs index 782b019..c0b61ab 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -49,14 +51,20 @@ data Connection = Connection connectionTempNameCounter :: {-# UNPACK #-} !(IORef Int64), hpgConn :: HPgConnection } +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) +#endif instance Eq Connection where x == y = hpgConn x == hpgConn y -- | Superclass for postgresql exceptions data SomePostgreSqlException = forall e. (Exception e) => SomePostgreSqlException e +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) +#endif postgresqlExceptionToException :: (Exception e) => e -> SomeException postgresqlExceptionToException = toException . SomePostgreSqlException @@ -83,7 +91,11 @@ data SqlError = SqlError -- to help debugging the source of errors. sqlStatement :: ByteString } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif fatalError :: ByteString -> SqlError fatalError msg = SqlError "" FatalError msg "" "" "" @@ -98,7 +110,11 @@ data QueryError = QueryError { qeMessage :: String, qeQuery :: Query } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance Exception QueryError where toException = postgresqlExceptionToException @@ -112,7 +128,11 @@ data FormatError = FormatError fmtQuery :: Query, fmtParams :: [ByteString] } - deriving (Eq, Show, Typeable) + deriving (Eq, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance Exception FormatError where toException = postgresqlExceptionToException @@ -125,7 +145,11 @@ data ConnectInfo = ConnectInfo connectPassword :: String, connectDatabase :: String } - deriving (Generic, Eq, Read, Show, Typeable) + deriving (Generic, Eq, Read, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | Default information for setting up a connection. -- @@ -240,7 +264,7 @@ withConnection Connection {..} m = m $ PQ.Connection hpgConn -- for detailed information regarding libpq and SSL. connectPostgreSQL :: ByteString -> IO Connection connectPostgreSQL connstr = do - connectionObjects <- newMVar (IntMap.empty) + connectionObjects <- newMVar IntMap.empty connectionTempNameCounter <- newIORef 0 case Hpgsql.Connection.parseLibpqConnectionString (TE.decodeUtf8 connstr) of Left err -> error err diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs index 6112635..49be08b 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -31,7 +33,9 @@ module Database.PostgreSQL.Simple.Ok where import Control.Applicative import Control.Exception import Control.Monad (MonadPlus (..)) -import Data.Typeable +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) +import Data.Typeable (Typeable) +#endif import qualified Control.Monad.Fail as Fail @@ -39,7 +43,11 @@ import qualified Control.Monad.Fail as Fail -- a difference list (or a tree?) data Ok a = Errors [SomeException] | Ok !a - deriving (Show, Typeable, Functor) + deriving (Show, Functor) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | Two 'Errors' cases are considered equal, regardless of what the -- list of exceptions looks like. @@ -79,6 +87,10 @@ instance Fail.MonadFail Ok where -- | a way to reify a list of exceptions into a single exception newtype ManyErrors = ManyErrors [SomeException] - deriving (Show, Typeable) + deriving (Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance Exception ManyErrors diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs index b192619..46b91f6 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -19,7 +21,9 @@ module Database.PostgreSQL.Simple.Range ) where +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) import Data.Typeable (Typeable) +#endif -- | Represents boundary of a range data RangeBound a @@ -27,11 +31,19 @@ data RangeBound a | Inclusive !a | Exclusive !a | PosInfinity - deriving (Show, Typeable, Eq, Functor) + deriving (Show, Eq, Functor) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | Generic range type data PGRange a = PGRange !(RangeBound a) !(RangeBound a) - deriving (Show, Typeable, Functor) + deriving (Show, Functor) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif empty :: PGRange a empty = PGRange PosInfinity NegInfinity diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs index 35824b9..e9f7626 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE UndecidableInstances #-} ------------------------------------------------------------------------------ @@ -33,7 +34,9 @@ import qualified Data.Text.Lazy as LT import Data.Time.Calendar.Compat (Day) import Data.Time.Compat (CalendarDiffTime, NominalDiffTime, UTCTime, ZonedTime) import Data.Time.LocalTime.Compat (LocalTime, TimeOfDay) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) import Data.Typeable (Typeable) +#endif import Data.UUID.Types (UUID) import Data.Vector (Vector) import Hpgsql.Builder (BinaryField (..)) @@ -54,7 +57,10 @@ data Action Many [Action] | -- | Just a static SQL fragment to render Plain LB.ByteString +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) +#endif instance Show Action where show (QueryArgument _) = "QueryArgument" diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs index b21816c..64dec1e 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -42,7 +43,9 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import Data.Tuple.Only (Only (..)) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) import Data.Typeable (Typeable) +#endif import Database.PostgreSQL.LibPQ (Oid (..)) import Database.PostgreSQL.Simple.Compat (toByteString) import Database.PostgreSQL.Simple.ToField (Action (..), ToField (..)) @@ -53,11 +56,19 @@ import Hpgsql.Types (PGArray (..), (:.) (..)) -- | A placeholder for the SQL @NULL@ value. data Null = Null - deriving (Read, Show, Typeable) + deriving (Read, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | A placeholder for the PostgreSQL @DEFAULT@ value. data Default = Default - deriving (Read, Show, Typeable) + deriving (Read, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | A query string. This type is intended to make it difficult to -- construct a SQL query by concatenating string fragments, as that is @@ -81,7 +92,11 @@ data Default = Default newtype Query = Query { fromQuery :: ByteString } - deriving (Eq, Ord, Typeable) + deriving (Eq, Ord) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance Show Query where show = show . fromQuery @@ -145,7 +160,11 @@ instance Monoid Query where -- be null or you want null treated sensibly as a component of @IN@ or -- @NOT IN@. newtype In a = In a - deriving (Eq, Ord, Read, Show, Typeable, Functor) + deriving (Eq, Ord, Read, Show, Functor) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance (ToField a) => ToField (In [a]) where toField (In []) = Plain "(NULL)" @@ -153,7 +172,11 @@ instance (ToField a) => ToField (In [a]) where -- | Wrap binary data for use as a @bytea@ value. newtype Binary a = Binary {fromBinary :: a} - deriving (Eq, Ord, Read, Show, Typeable, Functor) + deriving (Eq, Ord, Read, Show, Functor) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance ToField (Binary ByteString) @@ -165,7 +188,11 @@ instance ToPgField (Binary ByteString) where -- | Wrap text for use as sql identifier, i.e. a table or column name. newtype Identifier = Identifier {fromIdentifier :: Text} - deriving stock (Eq, Ord, Read, Show, Typeable) + deriving (Eq, Ord, Read, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif deriving newtype (IsString) instance ToField Identifier where @@ -177,7 +204,11 @@ instance Hashable Identifier where -- | Wrap text for use as (maybe) qualified identifier, i.e. a table -- with schema, or column with table. data QualifiedIdentifier = QualifiedIdentifier (Maybe Text) Text - deriving (Eq, Ord, Read, Show, Typeable) + deriving (Eq, Ord, Read, Show) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif instance ToField QualifiedIdentifier where toField (QualifiedIdentifier m n) = case m of @@ -201,7 +232,11 @@ instance IsString QualifiedIdentifier where else QualifiedIdentifier (Just x) (T.tail y) newtype Savepoint = Savepoint Query - deriving (Eq, Ord, Show, Read, Typeable) + deriving (Eq, Ord, Show, Read) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif -- | Represents a @VALUES@ table literal, usable as an alternative to -- 'Database.PostgreSQL.Simple.executeMany' and @@ -257,7 +292,11 @@ newtype Savepoint = Savepoint Query -- See for -- more information. data Values a = Values [QualifiedIdentifier] [a] - deriving (Eq, Ord, Show, Read, Typeable) + deriving (Eq, Ord, Show, Read) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) + -- Typeable is auto-derived for all types starting with GHC 9.12 + deriving (Typeable) +#endif interleaveFoldr :: (a -> [b] -> [b]) -> b -> [b] -> [a] -> [b] interleaveFoldr f b bs' as = foldr (\a bs -> b : f a bs) bs' as diff --git a/hpgsql/src/Hpgsql/Types.hs b/hpgsql/src/Hpgsql/Types.hs index 2378e93..a5fbf1d 100644 --- a/hpgsql/src/Hpgsql/Types.hs +++ b/hpgsql/src/Hpgsql/Types.hs @@ -107,12 +107,11 @@ instance FromPgField PgJson where -- into your type (from either json or jsonb), and to encode -- to jsonb. newtype Aeson a = Aeson {getAeson :: a} - deriving newtype (Eq) -#if MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) deriving stock (Functor, Read, Show) -#else + deriving newtype (Eq) +#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving stock (Show, Read, Typeable, Functor) + deriving stock (Typeable) #endif instance (FromJSON a) => FromPgField (Aeson a) where From cbd6aa5504ce03656667a9ce3b4a9996e4f80770 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 12:09:05 -0300 Subject: [PATCH 6/9] Add tested-with field to hpgsql-simple-compat.cabal too --- hpgsql-simple-compat/hpgsql-simple-compat.cabal | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hpgsql-simple-compat/hpgsql-simple-compat.cabal b/hpgsql-simple-compat/hpgsql-simple-compat.cabal index 2143b90..9c37e26 100644 --- a/hpgsql-simple-compat/hpgsql-simple-compat.cabal +++ b/hpgsql-simple-compat/hpgsql-simple-compat.cabal @@ -24,6 +24,11 @@ category: Database homepage: https://github.com/mzabani/hpgsql#readme bug-reports: https://github.com/mzabani/hpgsql/issues build-type: Simple +tested-with: + GHC ==9.6.7 + || ==9.8.4 + || ==9.10.3 + || ==9.12.2 source-repository head type: git From dc58370323286b7732ea204ee741245bb878880c Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 12:11:16 -0300 Subject: [PATCH 7/9] Fix fourmolu choking on deriving clauses --- .../src/Database/PostgreSQL/Simple/HStore/Implementation.hs | 3 ++- hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs index a542a07..3654e2d 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -74,11 +75,11 @@ class ToHStoreText a where -- | Represents escape text, ready to be the key or value to a hstore value newtype HStoreText = HStoreText Builder + deriving newtype (Semigroup, Monoid) #if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) #endif - deriving newtype (Semigroup, Monoid) instance ToHStoreText HStoreText where toHStoreText = id diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs index 64dec1e..3ee3320 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} + ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -189,11 +190,11 @@ instance ToPgField (Binary ByteString) where -- | Wrap text for use as sql identifier, i.e. a table or column name. newtype Identifier = Identifier {fromIdentifier :: Text} deriving (Eq, Ord, Read, Show) + deriving newtype (IsString) #if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -- Typeable is auto-derived for all types starting with GHC 9.12 deriving (Typeable) #endif - deriving newtype (IsString) instance ToField Identifier where toField (Identifier ident) = EscapeIdentifier $ encodeUtf8 ident From fab49cc75233e712d0ccd3c0fccdf2e413e4596f Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 12:26:37 -0300 Subject: [PATCH 8/9] Typeable has been derived since GHC 7.10, so we don't need all that CPP! --- .hlint.yaml | 1 - .../src/Database/PostgreSQL/Simple/Copy.hs | 9 ---- .../src/Database/PostgreSQL/Simple/Errors.hs | 9 ---- .../Database/PostgreSQL/Simple/FromField.hs | 6 --- .../Simple/HStore/Implementation.hs | 21 --------- .../Database/PostgreSQL/Simple/Internal.hs | 26 ----------- .../src/Database/PostgreSQL/Simple/Ok.hs | 13 ------ .../src/Database/PostgreSQL/Simple/Range.hs | 13 ------ .../src/Database/PostgreSQL/Simple/ToField.hs | 8 ---- .../src/Database/PostgreSQL/Simple/Types.hs | 43 +------------------ hpgsql/src/Hpgsql/Types.hs | 10 ----- 11 files changed, 1 insertion(+), 158 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index fd31108..76dc978 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -4,7 +4,6 @@ - arguments: - "--cpp-define=MIN_VERSION_base(a,b,c)=1" - - "--cpp-define=MIN_VERSION_GLASGOW_HASKELL(9,12,0,0)=0" - "-XQuasiQuotes" - "-XTemplateHaskell" - "-XOverloadedRecordDot" diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs index a1f6972..ac4681a 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Copy.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -44,9 +42,6 @@ import qualified Data.ByteString.Char8 as B import Data.Int (Int64) import qualified Data.Text as Text import Data.Text.Encoding (decodeUtf8) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif import Database.PostgreSQL.Simple.HpgsqlUtils (toHpgsqlQuery) import Database.PostgreSQL.Simple.Internal import Database.PostgreSQL.Simple.ToRow (ToRow) @@ -85,10 +80,6 @@ data CopyOutResult -- number of rows returned. CopyOutDone {-# UNPACK #-} !Int64 deriving (Eq, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | Feed some data to a @COPY FROM STDIN@ query. Note that -- the data does not need to represent a single row, or even an diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs index af3c9b0..3531955 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Errors.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ---------------------------------------------------------- @@ -29,9 +27,6 @@ where import Control.Exception as E import Data.Attoparsec.ByteString.Char8 import Data.ByteString (ByteString) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif import Database.PostgreSQL.Simple.Internal -- Examples of parsed error messages @@ -58,10 +53,6 @@ data ConstraintViolation | -- | Name of the exclusion violation constraint ExclusionViolation ByteString deriving (Show, Eq, Ord) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- Default instance should be enough instance Exception ConstraintViolation where diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs index 6f03a89..3a2b83b 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/FromField.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - -- | -- Module: Database.PostgreSQL.Simple.FromField -- Copyright: (c) 2011 MailRank, Inc. @@ -160,10 +158,6 @@ data ResultError errMessage :: String } deriving (Eq, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Exception ResultError where toException = postgresqlExceptionToException diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs index 3654e2d..422c0c2 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/HStore/Implementation.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -29,9 +27,6 @@ import qualified Data.Text as TS import qualified Data.Text.Encoding as TS import Data.Text.Encoding.Error (UnicodeException) import qualified Data.Text.Lazy as TL -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif class ToHStore a where toHStore :: a -> HStoreBuilder @@ -40,10 +35,6 @@ class ToHStore a where data HStoreBuilder = Empty | Comma !Builder -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToHStore HStoreBuilder where toHStore = id @@ -76,10 +67,6 @@ class ToHStoreText a where -- | Represents escape text, ready to be the key or value to a hstore value newtype HStoreText = HStoreText Builder deriving newtype (Semigroup, Monoid) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToHStoreText HStoreText where toHStoreText = id @@ -123,20 +110,12 @@ hstore (toHStoreText -> (HStoreText key)) (toHStoreText -> (HStoreText val)) = ) newtype HStoreList = HStoreList {fromHStoreList :: [(Text, Text)]} deriving (Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | hstore instance ToHStore HStoreList where toHStore (HStoreList xs) = mconcat (map (uncurry hstore) xs) newtype HStoreMap = HStoreMap {fromHStoreMap :: Map Text Text} deriving (Eq, Ord, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToHStore HStoreMap where toHStore (HStoreMap xs) = Map.foldrWithKey f mempty xs diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs index c0b61ab..fb159bc 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Internal.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -51,20 +49,12 @@ data Connection = Connection connectionTempNameCounter :: {-# UNPACK #-} !(IORef Int64), hpgConn :: HPgConnection } -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Eq Connection where x == y = hpgConn x == hpgConn y -- | Superclass for postgresql exceptions data SomePostgreSqlException = forall e. (Exception e) => SomePostgreSqlException e -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif postgresqlExceptionToException :: (Exception e) => e -> SomeException postgresqlExceptionToException = toException . SomePostgreSqlException @@ -92,10 +82,6 @@ data SqlError = SqlError sqlStatement :: ByteString } deriving (Eq, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif fatalError :: ByteString -> SqlError fatalError msg = SqlError "" FatalError msg "" "" "" @@ -111,10 +97,6 @@ data QueryError = QueryError qeQuery :: Query } deriving (Eq, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Exception QueryError where toException = postgresqlExceptionToException @@ -129,10 +111,6 @@ data FormatError = FormatError fmtParams :: [ByteString] } deriving (Eq, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Exception FormatError where toException = postgresqlExceptionToException @@ -146,10 +124,6 @@ data ConnectInfo = ConnectInfo connectDatabase :: String } deriving (Generic, Eq, Read, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | Default information for setting up a connection. -- diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs index 49be08b..a7fc005 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Ok.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -33,9 +31,6 @@ module Database.PostgreSQL.Simple.Ok where import Control.Applicative import Control.Exception import Control.Monad (MonadPlus (..)) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif import qualified Control.Monad.Fail as Fail @@ -44,10 +39,6 @@ import qualified Control.Monad.Fail as Fail data Ok a = Errors [SomeException] | Ok !a deriving (Show, Functor) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | Two 'Errors' cases are considered equal, regardless of what the -- list of exceptions looks like. @@ -88,9 +79,5 @@ instance Fail.MonadFail Ok where -- | a way to reify a list of exceptions into a single exception newtype ManyErrors = ManyErrors [SomeException] deriving (Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Exception ManyErrors diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs index 46b91f6..aa5b96e 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -21,9 +19,6 @@ module Database.PostgreSQL.Simple.Range ) where -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif -- | Represents boundary of a range data RangeBound a @@ -32,18 +27,10 @@ data RangeBound a | Exclusive !a | PosInfinity deriving (Show, Eq, Functor) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | Generic range type data PGRange a = PGRange !(RangeBound a) !(RangeBound a) deriving (Show, Functor) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif empty :: PGRange a empty = PGRange PosInfinity NegInfinity diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs index e9f7626..f591fb3 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/ToField.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE UndecidableInstances #-} ------------------------------------------------------------------------------ @@ -34,9 +33,6 @@ import qualified Data.Text.Lazy as LT import Data.Time.Calendar.Compat (Day) import Data.Time.Compat (CalendarDiffTime, NominalDiffTime, UTCTime, ZonedTime) import Data.Time.LocalTime.Compat (LocalTime, TimeOfDay) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif import Data.UUID.Types (UUID) import Data.Vector (Vector) import Hpgsql.Builder (BinaryField (..)) @@ -57,10 +53,6 @@ data Action Many [Action] | -- | Just a static SQL fragment to render Plain LB.ByteString -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Show Action where show (QueryArgument _) = "QueryArgument" diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs index 3ee3320..703ed06 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Types.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ @@ -44,9 +42,6 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import Data.Tuple.Only (Only (..)) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) -import Data.Typeable (Typeable) -#endif import Database.PostgreSQL.LibPQ (Oid (..)) import Database.PostgreSQL.Simple.Compat (toByteString) import Database.PostgreSQL.Simple.ToField (Action (..), ToField (..)) @@ -58,18 +53,10 @@ import Hpgsql.Types (PGArray (..), (:.) (..)) -- | A placeholder for the SQL @NULL@ value. data Null = Null deriving (Read, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | A placeholder for the PostgreSQL @DEFAULT@ value. data Default = Default deriving (Read, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | A query string. This type is intended to make it difficult to -- construct a SQL query by concatenating string fragments, as that is @@ -94,10 +81,6 @@ newtype Query = Query { fromQuery :: ByteString } deriving (Eq, Ord) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance Show Query where show = show . fromQuery @@ -162,10 +145,6 @@ instance Monoid Query where -- @NOT IN@. newtype In a = In a deriving (Eq, Ord, Read, Show, Functor) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance (ToField a) => ToField (In [a]) where toField (In []) = Plain "(NULL)" @@ -174,10 +153,6 @@ instance (ToField a) => ToField (In [a]) where -- | Wrap binary data for use as a @bytea@ value. newtype Binary a = Binary {fromBinary :: a} deriving (Eq, Ord, Read, Show, Functor) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToField (Binary ByteString) @@ -189,12 +164,8 @@ instance ToPgField (Binary ByteString) where -- | Wrap text for use as sql identifier, i.e. a table or column name. newtype Identifier = Identifier {fromIdentifier :: Text} - deriving (Eq, Ord, Read, Show) + deriving stock (Eq, Ord, Read, Show) deriving newtype (IsString) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToField Identifier where toField (Identifier ident) = EscapeIdentifier $ encodeUtf8 ident @@ -206,10 +177,6 @@ instance Hashable Identifier where -- with schema, or column with table. data QualifiedIdentifier = QualifiedIdentifier (Maybe Text) Text deriving (Eq, Ord, Read, Show) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif instance ToField QualifiedIdentifier where toField (QualifiedIdentifier m n) = case m of @@ -234,10 +201,6 @@ instance IsString QualifiedIdentifier where newtype Savepoint = Savepoint Query deriving (Eq, Ord, Show, Read) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif -- | Represents a @VALUES@ table literal, usable as an alternative to -- 'Database.PostgreSQL.Simple.executeMany' and @@ -294,10 +257,6 @@ newtype Savepoint = Savepoint Query -- more information. data Values a = Values [QualifiedIdentifier] [a] deriving (Eq, Ord, Show, Read) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving (Typeable) -#endif interleaveFoldr :: (a -> [b] -> [b]) -> b -> [b] -> [a] -> [b] interleaveFoldr f b bs' as = foldr (\a bs -> b : f a bs) bs' as diff --git a/hpgsql/src/Hpgsql/Types.hs b/hpgsql/src/Hpgsql/Types.hs index a5fbf1d..21fb011 100644 --- a/hpgsql/src/Hpgsql/Types.hs +++ b/hpgsql/src/Hpgsql/Types.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE CPP #-} - module Hpgsql.Types ( Only (..), Aeson (..), @@ -19,11 +17,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Lazy as LBS import Data.Tuple.Only (Only (..)) -#if MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) import Data.Typeable (Proxy (..)) -#else -import Data.Typeable (Proxy (..), Typeable) -#endif import Hpgsql.Builder (BinaryField (..)) import Hpgsql.Encoding (FieldDecoder (..), FieldEncoder (..), FieldInfo (..), FromPgField (..), FromPgRow (..), RowEncoder (..), ToPgField (..), ToPgRow (..), arrayField, toPgVectorField) import Hpgsql.TypeInfo (EncodingContext (..), TypeInfo (..), jsonOid, jsonbOid, lookupTypeByOid) @@ -109,10 +103,6 @@ instance FromPgField PgJson where newtype Aeson a = Aeson {getAeson :: a} deriving stock (Functor, Read, Show) deriving newtype (Eq) -#if !MIN_VERSION_GLASGOW_HASKELL(9,12,0,0) - -- Typeable is auto-derived for all types starting with GHC 9.12 - deriving stock (Typeable) -#endif instance (FromJSON a) => FromPgField (Aeson a) where fieldDecoder = From db4d25afe0e4dcdddcc73193438f85c81da6df59 Mon Sep 17 00:00:00 2001 From: Marcelo Zabani Date: Sun, 26 Jul 2026 12:33:38 -0300 Subject: [PATCH 9/9] Format file --- hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs index aa5b96e..3400082 100644 --- a/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs +++ b/hpgsql-simple-compat/src/Database/PostgreSQL/Simple/Range.hs @@ -19,7 +19,6 @@ module Database.PostgreSQL.Simple.Range ) where - -- | Represents boundary of a range data RangeBound a = NegInfinity