Use haskeline
This commit is contained in:
parent
86a7f2bc86
commit
7d10eb226d
16
hsilop.hs
16
hsilop.hs
@ -5,18 +5,18 @@ import Data.Maybe
|
|||||||
import Text.Read
|
import Text.Read
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import System.Console.Readline
|
import System.Console.Haskeline
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = runInputT defaultSettings repl
|
||||||
line <- readline "ꟼ "
|
|
||||||
|
repl :: InputT IO ()
|
||||||
|
repl = do
|
||||||
|
line <- getInputLine "ꟼ "
|
||||||
case fromMaybe "" line of
|
case fromMaybe "" line of
|
||||||
"" -> main
|
|
||||||
"q" -> return ()
|
"q" -> return ()
|
||||||
exp -> do
|
"" -> outputStrLn "" >> repl
|
||||||
putStrLn $ result (rpn exp) ++ "\n"
|
exp -> outputStrLn (result (rpn exp) ++ "\n") >> repl
|
||||||
addHistory exp
|
|
||||||
main
|
|
||||||
|
|
||||||
|
|
||||||
-- Pretty print RPN result/errors
|
-- Pretty print RPN result/errors
|
||||||
|
Loading…
Reference in New Issue
Block a user