Skip to content

Commit 82cef55

Browse files
authored
Merge pull request haskellari#36 from haskellari/atleast-ghc-8.6
Drop support for GHCs prior GHC-8.6
2 parents fc19817 + cc06a42 commit 82cef55

File tree

8 files changed

+43
-141
lines changed

8 files changed

+43
-141
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.15.20220826
11+
# version: 0.15.20221225
1212
#
13-
# REGENDATA ("0.15.20220826",["github","postgresql-libpq.cabal"])
13+
# REGENDATA ("0.15.20221225",["github","postgresql-libpq.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -30,7 +30,7 @@ jobs:
3030
image: buildpack-deps:bionic
3131
services:
3232
postgres:
33-
image: postgres:10
33+
image: postgres:14
3434
env:
3535
POSTGRES_PASSWORD: postgres
3636
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
@@ -68,51 +68,6 @@ jobs:
6868
compilerVersion: 8.6.5
6969
setup-method: hvr-ppa
7070
allow-failure: false
71-
- compiler: ghc-8.4.4
72-
compilerKind: ghc
73-
compilerVersion: 8.4.4
74-
setup-method: hvr-ppa
75-
allow-failure: false
76-
- compiler: ghc-8.2.2
77-
compilerKind: ghc
78-
compilerVersion: 8.2.2
79-
setup-method: hvr-ppa
80-
allow-failure: false
81-
- compiler: ghc-8.0.2
82-
compilerKind: ghc
83-
compilerVersion: 8.0.2
84-
setup-method: hvr-ppa
85-
allow-failure: false
86-
- compiler: ghc-7.10.3
87-
compilerKind: ghc
88-
compilerVersion: 7.10.3
89-
setup-method: hvr-ppa
90-
allow-failure: false
91-
- compiler: ghc-7.8.4
92-
compilerKind: ghc
93-
compilerVersion: 7.8.4
94-
setup-method: hvr-ppa
95-
allow-failure: false
96-
- compiler: ghc-7.6.3
97-
compilerKind: ghc
98-
compilerVersion: 7.6.3
99-
setup-method: hvr-ppa
100-
allow-failure: false
101-
- compiler: ghc-7.4.2
102-
compilerKind: ghc
103-
compilerVersion: 7.4.2
104-
setup-method: hvr-ppa
105-
allow-failure: false
106-
- compiler: ghc-7.2.2
107-
compilerKind: ghc
108-
compilerVersion: 7.2.2
109-
setup-method: hvr-ppa
110-
allow-failure: false
111-
- compiler: ghc-7.0.4
112-
compilerKind: ghc
113-
compilerVersion: 7.0.4
114-
setup-method: hvr-ppa
115-
allow-failure: false
11671
fail-fast: false
11772
steps:
11873
- name: apt
@@ -239,8 +194,8 @@ jobs:
239194
touch cabal.project
240195
touch cabal.project.local
241196
echo "packages: ${PKGDIR_postgresql_libpq}" >> cabal.project
242-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package postgresql-libpq" >> cabal.project ; fi
243-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
197+
echo "package postgresql-libpq" >> cabal.project
198+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
244199
cat >> cabal.project <<EOF
245200
EOF
246201
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(postgresql-libpq)$/; }' >> cabal.project.local

.github/workflows/simple.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [macos-latest, windows-latest]
17-
ghc: ['8.10','9.0','9.2','9.4.2']
17+
ghc: ['8.10','9.0','9.2','9.4.4']
1818
fail-fast: false
1919
timeout-minutes:
2020
60

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.9.5.0
2+
-------
3+
4+
- Drop support for GHCs prior 8.6
5+
16
0.9.4.3
27
-------
38

Setup.hs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{-# LANGUAGE CPP #-}
2-
3-
#ifndef MIN_VERSION_Cabal
4-
#define MIN_VERSION_Cabal(x,y,z) 0
5-
#endif
1+
module Main (main) where
62

73
import Distribution.Simple
84
import Distribution.Simple.Setup
@@ -16,30 +12,15 @@ import Distribution.Verbosity
1612
import Data.Char (isSpace)
1713
import Data.List (dropWhile,reverse)
1814

19-
#if MIN_VERSION_Cabal(2,0,0)
2015
import Distribution.Types.UnqualComponentName
21-
#endif
2216

2317
flag :: String -> FlagName
24-
#if MIN_VERSION_Cabal(2,0,0)
2518
flag = mkFlagName
26-
#else
27-
flag = FlagName
28-
#endif
2919

30-
#if MIN_VERSION_Cabal(2,0,0)
3120
unqualComponentName :: String -> UnqualComponentName
3221
unqualComponentName = mkUnqualComponentName
33-
#else
34-
unqualComponentName :: String -> String
35-
unqualComponentName = id
36-
#endif
37-
38-
#if !MIN_VERSION_Cabal(2,2,0)
39-
unFlagAssignment :: [(FlagName, Bool)] -> [(FlagName, Bool)]
40-
unFlagAssignment = id
41-
#endif
4222

23+
main :: IO ()
4324
main = defaultMainWithHooks simpleUserHooks {
4425
confHook = \pkg flags -> do
4526
if lookup (flag "use-pkg-config")

postgresql-libpq.cabal

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
cabal-version: 2.4
12
name: postgresql-libpq
2-
version: 0.9.4.3
3-
x-revision: 3
3+
version: 0.9.5.0
44
synopsis: low-level binding to libpq
55
description:
66
This is a binding to libpq: the C application
@@ -12,7 +12,7 @@ description:
1212

1313
homepage: https://github.com/haskellari/postgresql-libpq
1414
bug-reports: https://github.com/haskellari/postgresql-libpq/issues
15-
license: BSD3
15+
license: BSD-3-Clause
1616
license-file: LICENSE
1717
author: Grant Monroe, Leon P Smith, Joey Adams
1818
maintainer: Oleg Grenrus <[email protected]>
@@ -23,30 +23,15 @@ copyright:
2323
category: Database
2424
build-type: Custom
2525
extra-source-files: cbits/noticehandlers.h
26-
cabal-version: >=1.10
2726
tested-with:
28-
GHC ==7.0.4
29-
|| ==7.2.2
30-
|| ==7.4.2
31-
|| ==7.6.3
32-
|| ==7.8.4
33-
|| ==7.10.3
34-
|| ==8.0.2
35-
|| ==8.2.2
36-
|| ==8.4.4
37-
|| ==8.6.5
38-
|| ==8.8.4
39-
|| ==8.10.7
40-
|| ==9.0.2
41-
|| ==9.2.4
42-
|| ==9.4.2
27+
GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.4 || ==9.4.2
4328

4429
extra-source-files: CHANGELOG.md
4530

4631
custom-setup
4732
setup-depends:
48-
base >=4.3 && <5
49-
, Cabal >=1.10 && <3.9
33+
, base >=4.12.0.0 && <5
34+
, Cabal >=2.4 && <3.9
5035

5136
-- If true, use pkg-config, otherwise use the pg_config based build
5237
-- configuration
@@ -55,10 +40,10 @@ flag use-pkg-config
5540
manual: True
5641

5742
library
58-
default-language: Haskell2010
59-
hs-source-dirs: src
60-
c-sources: cbits/noticehandlers.c
61-
include-dirs: cbits
43+
default-language: Haskell2010
44+
hs-source-dirs: src
45+
c-sources: cbits/noticehandlers.c
46+
include-dirs: cbits
6247
exposed-modules:
6348
Database.PostgreSQL.LibPQ
6449
Database.PostgreSQL.LibPQ.Internal
@@ -71,19 +56,19 @@ library
7156
Database.PostgreSQL.LibPQ.Oid
7257

7358
build-depends:
74-
base >=4.3 && <4.18
75-
, bytestring >=0.9.1.0 && <0.12
59+
, base >=4.12.0.0 && <4.18
60+
, bytestring >=0.10.8.2 && <0.12
7661

7762
if !os(windows)
78-
build-depends: unix >=2.4.2.0 && <2.8
63+
build-depends: unix >=2.7.2.2 && <2.8
7964

8065
if os(windows)
8166
build-depends: Win32 >=2.2.0.2 && <2.14
8267

83-
ghc-options: -Wall
68+
ghc-options: -Wall
8469

8570
if flag(use-pkg-config)
86-
pkgconfig-depends: libpq ==9.3 || >9.3
71+
pkgconfig-depends: libpq >=9.3
8772

8873
else
8974
if os(windows)
@@ -102,16 +87,15 @@ library
10287
crypto
10388
ssl
10489

105-
-- Other-modules:
106-
build-tools: hsc2hs -any
90+
build-tool-depends: hsc2hs:hsc2hs >=0.68.5
10791

10892
test-suite smoke
10993
default-language: Haskell2010
11094
type: exitcode-stdio-1.0
11195
main-is: Smoke.hs
11296
hs-source-dirs: test
11397
build-depends:
114-
base
98+
, base
11599
, bytestring
116100
, postgresql-libpq
117101

src/Database/PostgreSQL/LibPQ.hs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
{-# LANGUAGE OverloadedStrings #-}
4444
{-# LANGUAGE ScopedTypeVariables #-}
4545
{-# LANGUAGE BangPatterns #-}
46+
{-# LANGUAGE DerivingStrategies #-}
4647
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
47-
{-# LANGUAGE DeriveDataTypeable #-}
4848

4949
module Database.PostgreSQL.LibPQ
5050
(
@@ -213,23 +213,18 @@ module Database.PostgreSQL.LibPQ
213213
)
214214
where
215215

216-
import Prelude hiding ( print )
216+
import Control.Exception (try, IOException, mask_)
217217
import Foreign
218218
import Foreign.C.Types
219219
import Foreign.C.String
220-
#if __GLASGOW_HASKELL__ >= 702
221220
import qualified Foreign.ForeignPtr.Unsafe as Unsafe
222-
#endif
223221
import qualified Foreign.Concurrent as FC
224222
import System.Posix.Types ( Fd(..) )
225223
import System.IO ( IOMode(..), SeekMode(..) )
226224

227-
#if __GLASGOW_HASKELL__ >= 700
228225
import GHC.Conc ( closeFdWith ) -- Won't work with GHC 7.0.1
229-
#endif
230226
import System.Posix.Types ( CPid )
231227

232-
import Data.ByteString.Char8 ()
233228
import qualified Data.ByteString.Unsafe as B
234229
import qualified Data.ByteString.Internal as B ( fromForeignPtr
235230
, c_strlen
@@ -246,14 +241,6 @@ import Database.PostgreSQL.LibPQ.Marshal
246241
import Database.PostgreSQL.LibPQ.Notify
247242
import Database.PostgreSQL.LibPQ.Oid
248243

249-
#if __GLASGOW_HASKELL__ >= 700
250-
import Control.Exception (mask_)
251-
#else
252-
import qualified Control.Exception
253-
mask_ = Control.Exception.block
254-
#endif
255-
256-
import Control.Exception (try, IOException)
257244

258245
#ifndef mingw32_HOST_OS
259246
import System.Posix.DynamicLinker
@@ -311,7 +298,6 @@ connectStart connStr =
311298

312299
pqfinish :: Ptr PGconn -> MVar NoticeBuffer -> IO ()
313300
pqfinish conn noticeBuffer = do
314-
#if __GLASGOW_HASKELL__ >= 700
315301
-- This covers the case when a connection is closed while other Haskell
316302
-- threads are using GHC's IO manager to wait on the descriptor. This is
317303
-- commonly the case with asynchronous notifications, for example. Since
@@ -324,9 +310,7 @@ pqfinish conn noticeBuffer = do
324310
-- This case may be worth investigating further
325311
c_PQfinish conn
326312
fd -> closeFdWith (\_ -> c_PQfinish conn) (Fd fd)
327-
#else
328-
c_PQfinish conn
329-
#endif
313+
330314
nb <- swapMVar noticeBuffer nullPtr
331315
c_free_noticebuffer nb
332316

@@ -350,11 +334,7 @@ newNullConnection = do
350334

351335
-- | Test if a connection is the Null Connection.
352336
isNullConnection :: Connection -> Bool
353-
#if __GLASGOW_HASKELL__ >= 702
354337
isNullConnection (Conn x _) = Unsafe.unsafeForeignPtrToPtr x == nullPtr
355-
#else
356-
isNullConnection (Conn x _) = unsafeForeignPtrToPtr x == nullPtr
357-
#endif
358338
{-# INLINE isNullConnection #-}
359339

360340
-- | If 'connectStart' succeeds, the next stage is to poll libpq so
@@ -1039,8 +1019,12 @@ nfields :: Result
10391019
nfields res = withResult res (return . toColumn . c_PQnfields)
10401020

10411021

1042-
newtype Column = Col CInt deriving (Eq, Ord, Show, Enum, Num)
1043-
newtype Row = Row CInt deriving (Eq, Ord, Show, Enum, Num)
1022+
newtype Column = Col CInt
1023+
deriving stock (Eq, Ord, Show)
1024+
deriving newtype (Enum, Num)
1025+
newtype Row = Row CInt
1026+
deriving stock (Eq, Ord, Show)
1027+
deriving newtype (Enum, Num)
10441028

10451029
toColumn :: (Integral a) => a -> Column
10461030
toColumn = Col . fromIntegral
@@ -2173,13 +2157,8 @@ foreign import ccall unsafe "libpq-fe.h PQsocket"
21732157
foreign import ccall "libpq-fe.h PQerrorMessage"
21742158
c_PQerrorMessage :: Ptr PGconn -> IO CString
21752159

2176-
#if __GLASGOW_HASKELL__ >= 700
21772160
foreign import ccall "libpq-fe.h PQfinish"
21782161
c_PQfinish :: Ptr PGconn -> IO ()
2179-
#else
2180-
foreign import ccall "libpq-fe.h &PQfinish"
2181-
p_PQfinish :: FunPtr (Ptr PGconn -> IO ())
2182-
#endif
21832162

21842163
foreign import ccall "libpq-fe.h PQreset"
21852164
c_PQreset :: Ptr PGconn -> IO ()

src/Database/PostgreSQL/LibPQ/Notify.hsc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ data Notify = Notify {
1919
, notifyExtra :: {-# UNPACK #-} !B.ByteString -- ^ notification payload string
2020
} deriving Show
2121

22-
#if __GLASGOW_HASKELL__ < 800
23-
#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
24-
#endif
2522
instance Storable Notify where
2623
sizeOf _ = #{size PGnotify}
2724

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
{-# LANGUAGE DeriveDataTypeable #-}
1+
{-# LANGUAGE DerivingStrategies #-}
22
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
33
module Database.PostgreSQL.LibPQ.Oid where
44

55
#include <libpq-fe.h>
66

7-
import Data.Typeable (Typeable)
87
import Foreign.C.Types (CUInt)
98
import Foreign.Storable (Storable)
109

11-
newtype Oid = Oid CUInt deriving (Eq, Ord, Read, Show, Storable, Typeable)
10+
newtype Oid = Oid CUInt
11+
deriving stock (Eq, Ord, Read, Show)
12+
deriving newtype (Storable)
1213

1314
invalidOid :: Oid
1415
invalidOid = Oid (#const InvalidOid)

0 commit comments

Comments
 (0)