Skip to content

Commit

Permalink
Switch from readline to haskeline
Browse files Browse the repository at this point in the history
Apparently `readline` doesn't build with newer versions of cabal.
  • Loading branch information
joncol committed Oct 9, 2024
1 parent 4c29aa0 commit 6d86e99
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
17 changes: 9 additions & 8 deletions examples/Catalog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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
)
Loading

0 comments on commit 6d86e99

Please sign in to comment.