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 51a02d5
Show file tree
Hide file tree
Showing 6 changed files with 2,137 additions and 9 deletions.
1,651 changes: 1,651 additions & 0 deletions .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc

Large diffs are not rendered by default.

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 51a02d5

Please sign in to comment.