From 44ba86e32bc1525053ad35cc96a4fc493bc6be1a Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Wed, 3 Oct 2012 15:01:20 -0400 Subject: [PATCH] Move REPL to Haskeline from editline --- LICENSE.INFO | 1 + dyna.cabal | 2 +- src/Dyna/REPL.hs | 20 ++++++++------------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/LICENSE.INFO b/LICENSE.INFO index bf1e30e..f841b69 100644 --- a/LICENSE.INFO +++ b/LICENSE.INFO @@ -5,6 +5,7 @@ We depend upon other projects (and their licenses) bytestring BSD3 containers BSD3 ghc The Glasgow Haskell Compiler License + haskeline BSD3 HUnit BSD3 mtl BSD3 reducers BSD3 diff --git a/dyna.cabal b/dyna.cabal index 80825ea..de97133 100644 --- a/dyna.cabal +++ b/dyna.cabal @@ -51,7 +51,7 @@ Executable drepl Build-Depends: base >=4, bytestring >=0.9, containers >=0.4, - editline >=0.2, + haskeline >=0.6, mtl >=2.1, parsers >=0.3, reducers >=3.0, diff --git a/src/Dyna/REPL.hs b/src/Dyna/REPL.hs index 3e6c278..5238380 100644 --- a/src/Dyna/REPL.hs +++ b/src/Dyna/REPL.hs @@ -2,7 +2,8 @@ module Dyna.REPL where import Control.Applicative ((<*)) -import System.Console.Editline +import Control.Monad.Trans (liftIO) +import System.Console.Haskeline import Text.Trifecta import qualified Dyna.ParserHS.Parser as DP @@ -12,12 +13,10 @@ import Dyna.XXX.Trifecta main :: IO () main = do - el <- elInit "dyna" - setEditor el Emacs - let + runInputT defaultSettings loop + where loop = do - setPrompt el (return "Dyna> ") - maybeLine <- elGets el + maybeLine <- getInputLine "Dyna> " case maybeLine of Nothing -> return () -- ctrl-D Just l -> triInteract (DP.dline <* eof) @@ -29,15 +28,12 @@ main = do -- Interaction interprets a ^D in nested context -- as an excuse to print out parsing errors -- (i.e. it why it rejected the line - promptCont = do - setPrompt el (return " ") - elGets el + promptCont = getInputLine " " success a = do - putStrLn $ "\nParsed: " ++ show a + outputStrLn $ "\nParsed: " ++ show a loop failure td = do - displayLn td + liftIO $ displayLn td loop - loop -- 2.50.1