From 05461356b8a931820510edcf9ca1c18e87b6672a Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 8 Mar 2026 19:19:19 +0100 Subject: [PATCH] Switch from readline to haskeline Some Linux distros have issues with installation of the readline package. --- examples/Catalog.hs | 15 +++++++-------- hpqtypes.cabal | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/Catalog.hs b/examples/Catalog.hs index 2501ef7..f17aa46 100644 --- a/examples/Catalog.hs +++ b/examples/Catalog.hs @@ -2,8 +2,8 @@ module Catalog (catalog) where import Control.Arrow (second) import Control.Monad -import Control.Monad.Base import Control.Monad.Catch +import Control.Monad.IO.Class import Data.Function import Data.Int import Data.Monoid.Utils @@ -11,12 +11,12 @@ 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'. -printLn :: MonadBase IO m => String -> m () -printLn = liftBase . putStrLn +printLn :: MonadIO m => String -> m () +printLn = liftIO . putStrLn -- | Get connection string from command line argument. getConnSettings :: IO ConnectionSettings @@ -144,13 +144,12 @@ 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 . fix $ \next -> + getInputLine "> " >>= maybe (printLn "") ( \cmd -> do when (cmd /= "quit") $ do - processCommand pool cmd - addHistory cmd + liftIO $ processCommand pool cmd next ) diff --git a/hpqtypes.cabal b/hpqtypes.cabal index 8490d67..7dd79a2 100644 --- a/hpqtypes.cabal +++ b/hpqtypes.cabal @@ -196,7 +196,7 @@ test-suite hpqtypes-tests , monad-control >= 1.0.3 , mtl >= 2.1 , random >= 1.0 - , readline >= 1.0.3.0 + , haskeline >= 0.8.0.0 , resource-pool >= 0.4 , scientific , test-framework >= 0.8