Use haskeline

This commit is contained in:
Rnhmjoj 2015-03-14 20:31:16 +01:00
parent 86a7f2bc86
commit 7d10eb226d

View File

@ -5,18 +5,18 @@ import Data.Maybe
import Text.Read
import Text.Printf
import Control.Monad
import System.Console.Readline
import System.Console.Haskeline
main :: IO ()
main = do
line <- readline ""
main = runInputT defaultSettings repl
repl :: InputT IO ()
repl = do
line <- getInputLine ""
case fromMaybe "" line of
"" -> main
"q" -> return ()
exp -> do
putStrLn $ result (rpn exp) ++ "\n"
addHistory exp
main
"" -> outputStrLn "" >> repl
exp -> outputStrLn (result (rpn exp) ++ "\n") >> repl
-- Pretty print RPN result/errors