From 8fabf1bb2ea1aa18e6b549160f75af8cfc16482a Mon Sep 17 00:00:00 2001 From: Jonas Collberg Date: Wed, 9 Oct 2024 10:33:16 +0200 Subject: [PATCH] Switch from `readline` to `haskeline` Apparently `readline` doesn't build with newer versions of cabal. Also update CI configuration to make it work, see: https://github.com/haskell-CI/haskell-ci/issues/738#issuecomment-2226402767 --- .github/workflows/haskell-ci.yml | 2 +- CHANGELOG.md | 4 ++++ cabal.haskell-ci | 1 + examples/Catalog.hs | 17 +++++++++-------- hpqtypes.cabal | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index aa25c57..ab99b93 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -27,7 +27,7 @@ jobs: timeout-minutes: 60 container: - image: buildpack-deps:bionic + image: buildpack-deps:jammy services: postgres: image: postgres:14 diff --git a/CHANGELOG.md b/CHANGELOG.md index 51656bd..4ef95f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# hpqtypes-1.12.1.0 (????-??-??) +* Switch from `readline` to `haskeline`, to make example compile with newer + Cabal versions. + # hpqtypes-1.12.0.0 (2024-03-18) * Drop support for GHC 8.8. * Attach `CallStack` and `BackendPid` to `DBException`. diff --git a/cabal.haskell-ci b/cabal.haskell-ci index a7a4a1b..9a89447 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -1,3 +1,4 @@ +distribution: jammy branches: master doctest: False tests: True diff --git a/examples/Catalog.hs b/examples/Catalog.hs index 2501ef7..5ef5d57 100644 --- a/examples/Catalog.hs +++ b/examples/Catalog.hs @@ -4,14 +4,14 @@ import Control.Arrow (second) import Control.Monad import Control.Monad.Base import Control.Monad.Catch -import Data.Function +import Control.Monad.IO.Class (liftIO) import Data.Int import Data.Monoid.Utils import Data.Pool import Data.Text qualified as T import Database.PostgreSQL.PQTypes import Database.PostgreSQL.PQTypes.Internal.Utils (mread) -import System.Console.Readline +import System.Console.Haskeline import System.Environment -- | Generic 'putStrLn'. @@ -144,13 +144,14 @@ catalog = do cs <- getConnSettings withCatalog cs $ do ConnectionSource pool <- poolSource (cs {csComposites = ["book_"]}) (\connect disconnect -> defaultPoolConfig connect disconnect 1 10) - fix $ \next -> - readline "> " + runInputT defaultSettings (loop pool) + where + loop pool = do + getInputLine "> " >>= maybe - (printLn "") + (outputStrLn "") ( \cmd -> do when (cmd /= "quit") $ do - processCommand pool cmd - addHistory cmd - next + liftIO $ processCommand pool cmd + loop pool ) diff --git a/hpqtypes.cabal b/hpqtypes.cabal index f0ca0b9..b153ea7 100644 --- a/hpqtypes.cabal +++ b/hpqtypes.cabal @@ -197,7 +197,7 @@ test-suite hpqtypes-tests , monad-control >= 1.0.3 , mtl >= 2.1 , random >= 1.0 - , readline >= 1.0.3.0 + , haskeline , resource-pool >= 0.4 , scientific , test-framework >= 0.8