From 7d10eb226d89e7ecc3d039e2a1120d793fe671eb Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Sat, 14 Mar 2015 20:31:16 +0100 Subject: [PATCH] Use haskeline --- hsilop.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hsilop.hs b/hsilop.hs index eb88440..41316bc 100644 --- a/hsilop.hs +++ b/hsilop.hs @@ -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