Skip to content

Commit b857568

Browse files
authored
Switch from readline to haskeline (#89)
Some Linux distros have issues with installation of the readline package.
1 parent a3dd161 commit b857568

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

examples/Catalog.hs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ module Catalog (catalog) where
22

33
import Control.Arrow (second)
44
import Control.Monad
5-
import Control.Monad.Base
65
import Control.Monad.Catch
6+
import Control.Monad.IO.Class
77
import Data.Function
88
import Data.Int
99
import Data.Monoid.Utils
1010
import Data.Pool
1111
import Data.Text qualified as T
1212
import Database.PostgreSQL.PQTypes
1313
import Database.PostgreSQL.PQTypes.Internal.Utils (mread)
14-
import System.Console.Readline
14+
import System.Console.Haskeline
1515
import System.Environment
1616

1717
-- | Generic 'putStrLn'.
18-
printLn :: MonadBase IO m => String -> m ()
19-
printLn = liftBase . putStrLn
18+
printLn :: MonadIO m => String -> m ()
19+
printLn = liftIO . putStrLn
2020

2121
-- | Get connection string from command line argument.
2222
getConnSettings :: IO ConnectionSettings
@@ -144,13 +144,12 @@ catalog = do
144144
cs <- getConnSettings
145145
withCatalog cs $ do
146146
ConnectionSource pool <- poolSource (cs {csComposites = ["book_"]}) (\connect disconnect -> defaultPoolConfig connect disconnect 1 10)
147-
fix $ \next ->
148-
readline "> "
147+
runInputT defaultSettings . fix $ \next ->
148+
getInputLine "> "
149149
>>= maybe
150150
(printLn "")
151151
( \cmd -> do
152152
when (cmd /= "quit") $ do
153-
processCommand pool cmd
154-
addHistory cmd
153+
liftIO $ processCommand pool cmd
155154
next
156155
)

hpqtypes.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test-suite hpqtypes-tests
196196
, monad-control >= 1.0.3
197197
, mtl >= 2.1
198198
, random >= 1.0
199-
, readline >= 1.0.3.0
199+
, haskeline >= 0.8.0.0
200200
, resource-pool >= 0.4
201201
, scientific
202202
, test-framework >= 0.8

0 commit comments

Comments
 (0)