diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/Main.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/Main.hs b/bin/Main.hs index a088fdb..54ed6b2 100644 --- a/bin/Main.hs +++ b/bin/Main.hs | |||
@@ -2,8 +2,9 @@ module Main where | |||
2 | 2 | ||
3 | import Control.Monad (liftM) | 3 | import Control.Monad (liftM) |
4 | import Control.Monad.Except (throwError) | 4 | import Control.Monad.Except (throwError) |
5 | import Error (LispError (..), LispResult (..), | 5 | import Error.Base (LispError (..), LispResult (..), |
6 | unwrap) | 6 | unwrap) |
7 | import Error.Pretty (defaults, showError) | ||
7 | import Evaluator (eval) | 8 | import Evaluator (eval) |
8 | import Parser (Expr (..), parseLispValue) | 9 | import Parser (Expr (..), parseLispValue) |
9 | import System.Console.Readline | 10 | import System.Console.Readline |
@@ -12,7 +13,7 @@ import Text.ParserCombinators.Parsec | |||
12 | 13 | ||
13 | readExpr :: String -> LispResult Expr | 14 | readExpr :: String -> LispResult Expr |
14 | readExpr inp = | 15 | readExpr inp = |
15 | case parse parseLispValue "(unknown)" inp of | 16 | case parse parseLispValue "(lisk-repl)" inp of |
16 | Left err -> throwError $ Parse err | 17 | Left err -> throwError $ Parse err |
17 | Right val -> return val | 18 | Right val -> return val |
18 | 19 | ||
@@ -26,7 +27,8 @@ repl = do | |||
26 | Just ",q" -> return () | 27 | Just ",q" -> return () |
27 | Just line -> do | 28 | Just line -> do |
28 | addHistory line | 29 | addHistory line |
29 | putStrLn $ either show show $ eval =<< readExpr line | 30 | let pp = showError defaults |
31 | either (putStrLn . pp line) print $ readExpr line >>= eval | ||
30 | repl | 32 | repl |
31 | 33 | ||
32 | main :: IO () | 34 | main :: IO () |