]> hydra-www.ietfng.org Git - dyna2/commitdiff
Move REPL to Haskeline from editline
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 3 Oct 2012 19:01:20 +0000 (15:01 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 3 Oct 2012 19:01:20 +0000 (15:01 -0400)
LICENSE.INFO
dyna.cabal
src/Dyna/REPL.hs

index bf1e30e6322a5de4dda4f3c0261672d7f5816ba8..f841b691f069fdf2cb766d361d82344156b67bac 100644 (file)
@@ -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
index 80825ea6ca2c484e112221ace82d2ae7978110de..de9713372f1cfe7291411caa6e97b901320fde96 100644 (file)
@@ -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,
index 3e6c2789aba89252317924431892f6e8b8c4da7d..5238380dd045a708d35e4be14320c8a151d315aa 100644 (file)
@@ -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